Skip to content

fix: Quote each column in composite foreign keys - #5821

Merged
marcelomendoncasoares merged 1 commit into
serverpod:mainfrom
mackings:fix/composite-foreign-key-quoting
Oct 5, 2026
Merged

marcelomendoncasoares merged 1 commit into
serverpod:mainfrom
mackings:fix/composite-foreign-key-quoting

Conversation

@mackings

@mackings mackings commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

The source columns of a foreign key were joined inside one pair of quotes, so a composite key produced FOREIGN KEY("tenantId, parentId"), which is invalid SQL. Each column is now quoted on its own, like the reference columns already are.

SQLite had the same code, so I fixed it there too. Single-column keys produce the same SQL as before.

Fixes #5735.

Pre-launch Checklist

  • I read the Contribute page and followed the process outlined there for submitting PRs.
  • This update contains only one single feature or bug fix and nothing else. (If you are submitting multiple fixes, please make multiple PRs.)
  • I read and followed the Dart Style Guide and formatted the code with dart format.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.
  • Any breaking changes are documented below.

If you need help, consider asking for advice on the discussion board.

Breaking changes

None.

The source columns of a foreign key were joined inside one pair of
quotes, so a composite key produced invalid SQL. Both the Postgres and
SQLite dialects now quote each column, the same way the reference
columns are quoted.

Fixes serverpod#5735.
@mackings

mackings commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

The one failing check is a Windows auth test (delete_password_reset_requests_test), not related to this change. It passes on Linux and macOS. Could someone re-run it?

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix, @mackings! 🚀

@marcelomendoncasoares
marcelomendoncasoares merged commit c763c4d into serverpod:main Oct 5, 2026
958 of 959 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PostgreSQL dialect emits invalid DDL for composite foreign keys (source columns joined inside one pair of quotes)

2 participants