Skip to content

Fix Unique Constraints in SQlite#922

Merged
parsonsmatt merged 1 commit intoyesodweb:matt/sqlite-unique-constraintsfrom
kderme:unique
Jul 17, 2019
Merged

Fix Unique Constraints in SQlite#922
parsonsmatt merged 1 commit intoyesodweb:matt/sqlite-unique-constraintsfrom
kderme:unique

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