beam icon indicating copy to clipboard operation
beam copied to clipboard

Sqlite migration fails with "default value of column is not constant"

Open thomasjm opened this issue 4 years ago • 1 comments

I'm finding that Sqlite migrations that use the defaultTo_ function don't work. I think it's because they try to use a wildcard to insert the default value.

I made a full repro here: https://github.com/thomasjm/beam-sqlite-default-repro

Here's what happens when you run it (formatted slightly for readability):

CREATE TABLE "repro"("id" INTEGER PRIMARY KEY AUTOINCREMENT, 
             "ref_count" INTEGER DEFAULT (?) NOT NULL );                                                                                                            
-- With values: [SQLInteger 0]                                                                                                                                                                                      
beam-sqlite-default-repro-exe: SQLite3 returned ErrorError while attempting to perform prepare 
"CREATE TABLE \"repro\"(\"id\" INTEGER PRIMARY KEY AUTOINCREMENT, 
              \"ref_count\" INTEGER DEFAULT (?) NOT NULL )": 
default value of column [ref_count] is not constant

thomasjm avatar Jan 13 '21 00:01 thomasjm

Interesting... I don't think placeholders are allowed in general for DDL in SQLite.

tathougies avatar Feb 12 '21 06:02 tathougies