Skip to content

Fix .references field constraint #191

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

Merged
merged 2 commits into from
Jul 29, 2020
Merged

Fix .references field constraint #191

merged 2 commits into from
Jul 29, 2020

Conversation

tanner0101
Copy link
Member

@tanner0101 tanner0101 commented Jul 28, 2020

Adds a fix for a MySQL syntax quirk that caused .references constraints to be ignored (#191, fixes #170).

MySQL does not allow the REFERENCES foreign_table (column_name) syntax like Fluent's other drivers do. When it sees this syntax, it simply ignores it with no warning. The only supported method for declaring for keys is to declare them as "table level" constraints. In other words, as a separate item in the create list.

This change causes MySQL's SQLSchemaConverter to automatically translate field-level foreign key constraints (.references) to their table-level counterparts.

@tanner0101 tanner0101 added the bug Something isn't working label Jul 28, 2020
@tanner0101
Copy link
Member Author

Relies on vapor/fluent-kit#364

@tanner0101 tanner0101 marked this pull request as ready for review July 29, 2020 01:27
@tanner0101 tanner0101 changed the title add field reference test + schema converter hook Convert field foreign keys to table constraints Jul 29, 2020
@tanner0101 tanner0101 changed the title Convert field foreign keys to table constraints Fix .references field constraint Jul 29, 2020
@tanner0101 tanner0101 added semver-minor Contains new APIs semver-patch Internal changes only and removed semver-minor Contains new APIs labels Jul 29, 2020
@tanner0101 tanner0101 merged commit 7901123 into master Jul 29, 2020
@tanner0101 tanner0101 deleted the tn-field-references branch July 29, 2020 01:44
@tanner0101
Copy link
Member Author

These changes are now available in 4.0.0-rc.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working semver-patch Internal changes only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

References and Foreign Key Constraints not being applied
1 participant