Possible inconsistency in database schema?

Still working on unravelling object structure into explicit SQL fields, I stumble on the name_group table containing fields name VARCHAR(50) and grouping TEXT. When queried, name is associated with family name which is defined as STRING (without any length specification).

I know that SQLite has implemented a “flexible typing feature” where, among other effects, all character data are treated the same as TEXT, so that storing the original STRING name into a VARCHAR(50) incurs no truncation in any circumstances.

However, if other DB engines, e.g. PostgreSQL, are used with the same gramps/plugins/db/dpapi.py DB generator, a surname might be truncated if it is longer than 50 characters. Depending on whether combining diacritical marks are counted as “characters” (in other words, field length is based on number of Unicode codepoints, not on number of human-seen composite glyphs – the latter results in problems for dimensioning fixed-length fields), this limit can be reached quite soon in languages using diacritics.

I imagine the size limit is a consequence of associating a PRIMARY KEY to the name field because you can’t index a TEXT field or an unlimited string, though it is difficult to say because surprisingly CREATE INDEX is not part of the SQL standard.

The effect would be faulty grouping. Not very serious but might surprise and confuse users.

Should this be considered a bug?

As already mentioned, there is no impact with SQLite.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.