Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix insertion of default values #206

Merged
merged 1 commit into from
Oct 17, 2022
Merged

Conversation

shane-circuithub
Copy link
Contributor

@shane-circuithub shane-circuithub commented Oct 17, 2022

At some point, possibly due to a change in Opaleye, insertion of default values (using unsafeDefault) stopped working in Rel8.

In general, PostgreSQL only allows insertion of default values in insert statements that have the form INSERT INTO table VALUES (DEFAULT). The way Opaleye typically generates SQL, the Rel8 equivalent to that code would come out looking more like INSERT INTO table SELECT * FROM (VALUES (DEFAULT)) q. Because the VALUES is wrapped in a SELECT, the DEFAULT becomes invalud PostgreSQL syntax.

To get around this, we special case VALUES when generating SQL for INSERT statements. However, something in the Opaleye representation changed and this special case was no longer firing. This commit fixes that.

At some point, possibly due to a change in Opaleye, insertion of default values (using `unsafeDefault`) stopped working in Rel8.

In general, PostgreSQL only allows insertion of default values in insert statements that have the form `INSERT INTO table VALUES (DEFAULT)`. The way Opaleye typically SQL, the Rel8 equivalent to that code would come out looking more like `INSERT INTO table SELECT * FROM (VALUES (DEFAULT)) q`. Because the `VALUES` is wrapped in a `SELECT`, the `DEFAULT` becomes invalud PostgreSQL syntax.

To get around this, we special case `VALUES` when generating SQL for INSERT statements. However, something in the Opaleye representation changed and this special case was no longer firing. This commit fixes that.
@shane-circuithub shane-circuithub merged commit 5eb5689 into master Oct 17, 2022
@shane-circuithub shane-circuithub deleted the fix-insert-default branch October 17, 2022 10:04
@istathar
Copy link

Any chance of cutting a 1.4.0.1 release with this fix in it?

@ocharles
Copy link
Contributor

@istathar Yessir. Working on it in #226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants