Hi! Welcome to the list.

I'm reading documentation on the topic:

"In an elegant system, all tables would behave as WITHOUT ROWID tables even
without the WITHOUT ROWID keyword".
then
"However, NOT NULL was not enforced on PRIMARY KEY columns by early
versions of SQLite due to a bug. By the time that this bug was discovered,
so many SQLite databases were already in circulation that the decision was
made not to fix this bug for fear of breaking compatibility."
at https://www.sqlite.org/withoutrowid.html

I suggest a possible solution to make it more elegant and more compliant.
There could be PRAGMA directives to opt-in for compliant behavior:

PRAGMA default_without_rowid = on
To make all tables created while the directive is in use the WITHOUT ROWID
tables.

PRAGMA enforce_not_null_on_primary_key = on
For WITHOUT ROWID tables it would be a no-op, but for rowid tables it would
restore correct behavior.

I think these changes would not add a lot of code to sqlite and will make
life easier for users.

In spirit it would be similar to already existing
PRAGMA foreign_keys = on

(I also wanted to suggest the same to be able to select behaviour of NULL
values in unique index, but am too shy to do it).

Just a thought.

Thanks!
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to