diff --git a/DB-record/src/Database/Record/KeyConstraint.hs b/DB-record/src/Database/Record/KeyConstraint.hs index 0beac335..04e92efe 100644 --- a/DB-record/src/Database/Record/KeyConstraint.hs +++ b/DB-record/src/Database/Record/KeyConstraint.hs @@ -16,7 +16,7 @@ -- of table constraint specifiey by keys. module Database.Record.KeyConstraint ( -- * Constraint specifiey by keys - KeyConstraint, index, specifyKeyConstraint, + KeyConstraint, index, unsafeSpecifyKeyConstraint, Unique, UniqueConstraint, NotNull, NotNullConstraint, @@ -31,7 +31,7 @@ module Database.Record.KeyConstraint ( derivedUniqueConstraint, derivedNotNullConstraint, - specifyNotNullValue + unsafeSpecifyNotNullValue ) where @@ -62,16 +62,16 @@ type NotNullConstraint = KeyConstraint NotNull type PrimaryConstraint = KeyConstraint Primary -- | Unsafely generate 'KeyConstraint' proof object using specified key index. -specifyKeyConstraint :: Int -> KeyConstraint c r -specifyKeyConstraint = KeyConstraint +unsafeSpecifyKeyConstraint :: Int -> KeyConstraint c r +unsafeSpecifyKeyConstraint = KeyConstraint -- | Derivation rule for 'UniqueConstraint'. unique :: PrimaryConstraint r -> UniqueConstraint r -unique = specifyKeyConstraint . index +unique = unsafeSpecifyKeyConstraint . index -- | Derivation rule for 'NotNullConstraint'. notNull :: PrimaryConstraint r -> NotNullConstraint r -notNull = specifyKeyConstraint . index +notNull = unsafeSpecifyKeyConstraint . index -- | Derivation rule of 'KeyConstraint' for tuple (,) type. @@ -98,5 +98,5 @@ derivedNotNullConstraint = notNull keyConstraint -- | Unsafely generate 'NotNullConstraint' proof object of single column value. -specifyNotNullValue :: NotNullConstraint a -specifyNotNullValue = specifyKeyConstraint 0 +unsafeSpecifyNotNullValue :: NotNullConstraint a +unsafeSpecifyNotNullValue = unsafeSpecifyKeyConstraint 0 diff --git a/DB-record/src/Database/Record/TH.hs b/DB-record/src/Database/Record/TH.hs index 78173aa1..7bd4a79f 100644 --- a/DB-record/src/Database/Record/TH.hs +++ b/DB-record/src/Database/Record/TH.hs @@ -56,7 +56,7 @@ import Database.Record ToSql(recordToSql), recordToSql') import Database.Record.KeyConstraint - (specifyKeyConstraint, specifyNotNullValue) + (unsafeSpecifyKeyConstraint, unsafeSpecifyNotNullValue) import Database.Record.Persistable (persistableRecord, persistableRecordWidth) import qualified Database.Record.Persistable as Persistable @@ -75,7 +75,7 @@ recordTypeDefault = toTypeCon . recordTypeNameDefault defineHasKeyConstraintInstance :: TypeQ -> TypeQ -> Int -> Q [Dec] defineHasKeyConstraintInstance constraint typeCon index = [d| instance HasKeyConstraint $constraint $typeCon where - keyConstraint = specifyKeyConstraint $(integralE index) |] + keyConstraint = unsafeSpecifyKeyConstraint $(integralE index) |] -- | Generate template of 'HasKeyConstraint' 'NotNull' instance. defineHasNotNullKeyInstance :: TypeQ -> Int -> Q [Dec] @@ -302,5 +302,5 @@ deriveNotNullType typeCon = persistableWidth = Persistable.valueWidth instance HasKeyConstraint NotNull $typeCon where - keyConstraint = specifyNotNullValue + keyConstraint = unsafeSpecifyNotNullValue |] diff --git a/relational-join/src/Database/Relational/Query/Constraint.hs b/relational-join/src/Database/Relational/Query/Constraint.hs index 32b7bfd4..920a3f31 100644 --- a/relational-join/src/Database/Relational/Query/Constraint.hs +++ b/relational-join/src/Database/Relational/Query/Constraint.hs @@ -18,7 +18,7 @@ module Database.Relational.Query.Constraint ( import Database.Relational.Query.Pi (Pi, leafIndex) import Database.Relational.Query.Pi.Unsafe (defineColumn) import Database.Record.KeyConstraint - (KeyConstraint, specifyKeyConstraint, + (KeyConstraint, unsafeSpecifyKeyConstraint, Primary, Unique, NotNull) import qualified Database.Record.KeyConstraint as C @@ -29,7 +29,7 @@ defineConstraintKey :: Int -> Key c r ct defineConstraintKey = Key recordConstraint :: Key c r ct -> KeyConstraint c r -recordConstraint = specifyKeyConstraint . index +recordConstraint = unsafeSpecifyKeyConstraint . index projectionKey :: Key c r ct -> Pi r ct projectionKey = defineColumn . index