On Sun, May 19, 2013 at 06:05:05PM -0400, Stephen Chrzanowski scratched on the wall: > I've been talking with Bogdan about a change to SQLite Expert and ran > across something I did NOT expect. > > I have this schema: > > CREATE TABLE [tApplicationPaths] ( > [AppID] INTEGER PRIMARY KEY, > [ApplicationName] CHAR, > [ApplicationMonitorPath] CHAR, > [SearchSubDirs] BOOL DEFAULT 1, > [SearchMask] CHAR DEFAULT AppID); > > When I insert a new row, I get the literal string "AppID" as a default > value for that new row. I was expecting a number or null, or something. > Not a string. Is this intended behavior?
As shown here: http://sqlite.org/syntaxdiagrams.html#column-constraint bare words are considered literal values. If you want to reference a column, you need to use parens to create an expression. SQLite correctly identifies this as invalid: sqlite> CREATE TABLE [tApplicationPaths] ( ...> [AppID] INTEGER PRIMARY KEY, ...> [ApplicationName] CHAR, ...> [ApplicationMonitorPath] CHAR, ...> [SearchSubDirs] BOOL DEFAULT 1, ...> [SearchMask] CHAR DEFAULT (AppID) ); Error: default value of column [SearchMask] is not constant -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users