Should the line uuid UUID DEFAULT genrandomuuid(), in INSERT INTO not automagically…
- User
Should the line
uuid UUID DEFAULT gen_random_uuid(),inINSERT INTOnot automagically generate a UUID for me if the field is NULL? Assistant
No — the
DEFAULTclause only applies when the column is omitted entirely from theINSERTstatement.
If you explicitly include the column and set it toNULL, PostgreSQL will not apply the default value.Example:
sqlCREATE TABLE users ( id UUID DEFAULT gen_random_uuid(), name TEXT );✅ This will use the default:
sqlINSERT INTO users (name) VALUES ('Alice'); -- id is auto-generated❌ This will insert NULL:
sqlINSERT INTO users (id, name) VALUES (NULL, 'Bob'); -- id is NULL, not auto-generated
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.