Open mlaster opened 2 years ago
Issues are used to track bugs and feature requests. Need help or have a general question? Ask on Stack Overflow (tag sqlite.swift).
Column check constraints seem to generate invalid SQL:
I'm creating a table with:
let validTypeRange = 0...26 try connection.writeConnection.savepoint { try connection.writeConnection.run(observations.create { builder in builder.column(Expression.identifier) builder.column(Expression.date) builder.column(Expression.type, check: validTypeRange ~= Expression.type) // builder.check(validTypeRange ~= Expression.type) })
And it generates a syntax error:
[logging] near ""type"": syntax error in "CREATE TABLE "Observations" ("identifier" BLOB NOT NULL, "date" TEXT NOT NULL, "type" INTEGER NOT NULL CHECK "type" BETWEEN 0 AND 26)"
If I use table checks instead of column checks, it works fine.
Expression.type is:
Expression("type")
It looks like the parens are missing around CHECK:
CHECK
"type" INTEGER NOT NULL (CHECK "type" BETWEEN 0 AND 26)
Can you paste the whole generated SQL by the table builder, before it gets executed?
Build Information
General guidelines
Column check constraints seem to generate invalid SQL:
I'm creating a table with:
And it generates a syntax error:
If I use table checks instead of column checks, it works fine.
Expression.type is:
Expression("type")