Closed abigailalice closed 3 months ago
This is a known issue, DEFAULT
can only INSERT
statements that are built with VALUES
. It's just how Postgres's syntax works. But you're right we should probably clarify this in the documentation.
This is now added to the documentation for unsafeDefault
@shane-circuithub. Should this be left open in case anyone ever decided to rewrite the trivial inserts to prevent the actual issue? I'm fine with it being closed, considering how small an issue it is, and that the name already alerts people to check the docs.
I think I'm OK with the status quo for now
I recently switched from Opaleye to Rel8, and noticed on inserts the
unsafeDefault
function generates invalid sql if the rows field is populated likerows = pure $ Row { key = unsafeDefault }
, generating aDEFAULT is not allowed in this context
error message.Using
rows = values [Row {key = unsafeDefault}]
seems to fix the issue, so I assume it's an issue with Rel8 generating SQL with an explicit select statement in thepure
case, but not with a trivial use ofvalues
. I don't know if that should be considered a bug or not, since it's already marked unsafe; it could arguably fall under the "DEFAULT values can not be transformed" caveat. But if it is considered an example of that,pure
is probably still trivial enough to warrant that being explicitly stated in the documentation.