5

When synchronizing an offline Spatialite file with it's corresponding PostGIS database, using the Offline Editing plugin in QGIS, I received an error I hadn't experienced before

enter image description here

The error message is quite clear, I had entered more than 254 characters in a attribute field that in the PostGIS table had this field length.

I looked at the properties of the offline Spatialite table and all the attribute length and precisions are all '0', or undefined. enter image description here

In the original PostGIS database table they are defined

enter image description here

Even if the Spatialite attribute that is too long is corrected, the synchronising of the offline Spatialite file now gives a commit error, which means all the changes made offline will now not synchronise.

enter image description here

My question

Is it possible to bring across the attribute field lengths from the PostGIS table to the Spatialite file so as to not allow attributes that are too long to be entered in the first instance?

  • 1
    I do not know if it is possible but if it is then it is some QGIS specific solutions because SQLite just doesn't care. From sqlite.org/datatype3.html Note that numeric arguments in parentheses that following the type name (ex: "VARCHAR(255)") are ignored by SQLite - SQLite does not impose any length restrictions (other than the large global SQLITE_MAX_LENGTH limit) on the length of strings, BLOBs or numeric values. – user30184 Sep 4 '17 at 10:23
  • @user30184 I wonder if you could make your comment into an answer so that it leaves the unanswered category? – Martin Hügi Apr 5 '18 at 16:52
2

With all credit to user30184 who answered in the comments...

SQLite just doesn't care. From sqlite.org/datatype3.html

Note that numeric arguments in parentheses that following the type name (ex: "VARCHAR(255)") are ignored by SQLite - SQLite does not impose any length restrictions (other than the large global SQLITE_MAX_LENGTH limit) on the length of strings, BLOBs or numeric values.

So the answer to the question is No, it is not possible to bring across the attribute field lengths from the PostGIS table to the Spatialite file.

This means that there is no limit to the length of what you can enter in the attribute fields. This is fine if you are working in SQLite and you want to stay working in SQLite, however if you then want to synchronise an SQLite database that was 'offlined' from a PostGIS database you will run into problems if the field lengths are greater than those set up in the PostGIS database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.