pawelsalawa / sqlitestudio

A free, open source, multi-platform SQLite database manager.
https://sqlitestudio.pl
Other
4.67k stars 571 forks source link

Field Default value not inserted when adding new record in Table grid #5094

Closed gmuskie closed 2 weeks ago

gmuskie commented 2 weeks ago

Details

A Default value for a filed has been specified in the stucture. When adding new record in Tables grid, nothing happend. It showed NULL value. However, no problem when running in SQL Editor.

Steps to reproduce

image

image

image

image

image

Operating system

Windows 10 Pro 22H2

SQLiteStudio version

v3.4.4

pawelsalawa commented 2 weeks ago

The DEFAULT is used by SQLite when value for certain column is not provided during insertion.

When you insert from table view, the whole row of data is inserted. All columns. It is you, who enter values for the row before commit. NULL value is correct for your column and SQLiteStudio must allow you to insert NULL.

If you want to enforce default values for a column during insertion of NULL values, add NOT NULL constraint to your DEFAULT column. It will enforce SQLiteStudio to use DEFAULT when value is NULL.