Skip to content

Fix Unique Constraints in SQlite #922

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 1 commit into from
Jul 17, 2019

Conversation

kderme
Copy link
Contributor

@kderme kderme commented Jun 27, 2019

SQlite seems to ignore Unique Keys when there is a Primary Key.

This

share [mkPersist sqlSettings, mkSave "entityDefs"] [persistLowerCase|
Person
    name String
    creditcard Int
    Primary name
    UniqueA creditcard
|]

translates into
CREATE TABLE "person"("name" VARCHAR NOT NULL,"creditcard" INTEGER NOT NULL, PRIMARY KEY ("name"))

while after the fix
CREATE TABLE "person"("name" VARCHAR NOT NULL,"creditcard" INTEGER NOT NULL, PRIMARY KEY ("name"),CONSTRAINT "unique_a" UNIQUE ("creditcard"))

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

@parsonsmatt
Copy link
Collaborator

Can you force-push an empty commit to get the CI to build?

@parsonsmatt parsonsmatt changed the base branch from master to matt/sqlite-unique-constraints July 17, 2019 00:08
@parsonsmatt
Copy link
Collaborator

I'm going to merge as-is into a new branch, which should trigger CI.

@parsonsmatt parsonsmatt merged commit f2c2b19 into yesodweb:matt/sqlite-unique-constraints Jul 17, 2019
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.

2 participants