yesodweb/persistent

newtype interferes with unique constraints in MySQL

Offen

#100 geöffnet am 29.10.2012

 (11 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Haskell (302 Forks)auto 404
Feature RequestMySQLgood first issue

Repository-Metriken

Stars
 (484 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Text fields can have unique constraints over them.

However, when a Text field is newtype'd, for extra type safety, this facility appears to break:

In Model.hs with GeneralizedNewtypeDeriving:

newtype Hash = Hash { unHash :: Text }
    deriving (Show, Read, Eq, PathPiece, PersistField)

In config/models:

Profile
  hash Hash
  UniqueHash hash

On initial database migration with mysql, we see:

Migrating: ALTER TABLE `profile` ADD CONSTRAINT `unique_hash` UNIQUE(`hash`)
hpd3js: ConnectionError {errFunction = "query", errNumber = 1170, errMessage = "BLOB/TEXT column 'hash' used in key specification without a key length"}

Uncaught instance of overlapping instances floating around, perhaps? (Am I missing a deriving statement?)

Contributor Guide