relational-query 0.8.3.8 → 0.8.3.9
raw patch · 4 files changed
+34/−8 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Database.Relational.Query.Projectable: nothing :: (OperatorProjectable (Projection c), SqlProjectable (Projection c), PersistableWidth a) => Projection c (Maybe a)
- Database.Relational.Query.Projectable: caseMaybe :: OperatorProjectable (Projection c) => Projection c a -> [(Projection c a, Projection c (Maybe b))] -> Projection c (Maybe b)
+ Database.Relational.Query.Projectable: caseMaybe :: (OperatorProjectable (Projection c), PersistableWidth b) => Projection c a -> [(Projection c a, Projection c (Maybe b))] -> Projection c (Maybe b)
- Database.Relational.Query.Projectable: caseSearchMaybe :: OperatorProjectable (Projection c) => [(Projection c (Maybe Bool), Projection c (Maybe a))] -> Projection c (Maybe a)
+ Database.Relational.Query.Projectable: caseSearchMaybe :: (OperatorProjectable (Projection c), PersistableWidth a) => [(Projection c (Maybe Bool), Projection c (Maybe a))] -> Projection c (Maybe a)
- Database.Relational.Query.Projectable: unsafeValueNull :: OperatorProjectable p => p (Maybe a)
+ Database.Relational.Query.Projectable: unsafeValueNull :: (OperatorProjectable (Projection c), SqlProjectable (Projection c), PersistableWidth a) => Projection c (Maybe a)
Files
- ChangeLog.md +4/−0
- relational-query.cabal +1/−1
- src/Database/Relational/Query/Projectable.hs +18/−7
- test/sqlsEq.hs +11/−0
ChangeLog.md view
@@ -1,5 +1,9 @@ <!-- -*- Markdown -*- --> +## 0.8.3.9++- Fix of unsafeValueNull. ( https://github.com/khibino/haskell-relational-record/issues/55 )+ ## 0.8.3.8 - Bugfix of case projected record. ( https://github.com/khibino/haskell-relational-record/issues/54 )
relational-query.cabal view
@@ -1,5 +1,5 @@ name: relational-query-version: 0.8.3.8+version: 0.8.3.9 synopsis: Typeful, Modular, Relational, algebraic query engine description: This package contiains typeful relation structure and relational-algebraic query building DSL which can
src/Database/Relational/Query/Projectable.hs view
@@ -21,7 +21,7 @@ value, valueTrue, valueFalse, values,- unsafeValueNull,+ nothing, unsafeValueNull, -- * Placeholders PlaceHolders, unsafeAddPlaceHolders, unsafePlaceHolders,@@ -73,8 +73,9 @@ import qualified Language.SQL.Keyword as SQL import Database.Record- (PersistableWidth, PersistableRecordWidth, derivedWidth,+ (PersistableWidth, persistableWidth, PersistableRecordWidth, derivedWidth, HasColumnConstraint, NotNull)+import Database.Record.Persistable (runPersistableRecordWidth) import Database.Relational.Query.Internal.SQL (StringSQL, stringSQL, showStringSQL) import qualified Database.Relational.Query.Internal.Sub as Internal@@ -125,10 +126,20 @@ unsafeProjectSql :: SqlProjectable p => String -> p t unsafeProjectSql = unsafeProjectSql' . stringSQL --- | Polymorphic projection of SQL null value.-unsafeValueNull :: OperatorProjectable p => p (Maybe a)-unsafeValueNull = unsafeProjectSql "NULL"+-- | Polymorphic projection of SQL null value. Semantics of comparing is unsafe.+nothing :: (OperatorProjectable (Projection c), SqlProjectable (Projection c), PersistableWidth a)+ => Projection c (Maybe a)+nothing = proxyWidth persistableWidth+ where+ proxyWidth :: SqlProjectable (Projection c) => PersistableRecordWidth a -> Projection c (Maybe a)+ proxyWidth w = unsafeProjectSqlTerms' $ replicate (runPersistableRecordWidth w) SQL.NULL +{-# DEPRECATED unsafeValueNull "Use `nothing' instead of this." #-}+-- | Deprecated. Polymorphic projection of SQL null value.+unsafeValueNull :: (OperatorProjectable (Projection c), SqlProjectable (Projection c), PersistableWidth a)+ => Projection c (Maybe a)+unsafeValueNull = nothing+ -- | Generate polymorphic projection of SQL constant values from Haskell value. value :: (ShowConstantTermsSQL t, OperatorProjectable p) => t -> p t value = unsafeProjectSqlTerms' . showConstantTermsSQL'@@ -376,7 +387,7 @@ casesOrElse = caseSearch -- | Null default version of 'caseSearch'.-caseSearchMaybe :: OperatorProjectable (Projection c) -- (Projection c) is always ProjectableMaybe+caseSearchMaybe :: (OperatorProjectable (Projection c) {- (Projection c) is always ProjectableMaybe -}, PersistableWidth a) => [(Projection c (Maybe Bool), Projection c (Maybe a))] -- ^ Each when clauses -> Projection c (Maybe a) -- ^ Result projection caseSearchMaybe cs = caseSearch cs unsafeValueNull@@ -398,7 +409,7 @@ casesOrElse' = uncurry case' -- | Null default version of 'case''.-caseMaybe :: OperatorProjectable (Projection c) -- (Projection c) is always ProjectableMaybe+caseMaybe :: (OperatorProjectable (Projection c) {- (Projection c) is always ProjectableMaybe -}, PersistableWidth b) => Projection c a -- ^ Projection value to match -> [(Projection c a, Projection c (Maybe b))] -- ^ Each when clauses -> Projection c (Maybe b) -- ^ Result projection
test/sqlsEq.hs view
@@ -340,6 +340,14 @@ .*. value 10 +caseRecordMaybeX :: Relation () (Maybe (Int32, String))+caseRecordMaybeX = relation $ do+ return $+ caseMaybe+ (value (5 :: Int32))+ [ (value (1 :: Int32) , just $ (,) |$| value (1 :: Int32) |*| value "foo")+ , (value 3 .+. value 2 , just $ (,) |$| value 2 |*| value "bar") ]+ cases :: [Test] cases = [ eqProp "caseSearch" caseSearchX@@ -348,6 +356,9 @@ "SELECT ALL CASE 5 WHEN 1 THEN 'foo' WHEN (3 + 2) THEN 'bar' WHEN 10 THEN 'baz' ELSE 'other' END AS f0" , eqProp "caseRecord" caseRecordX "SELECT ALL (CASE 5 WHEN 1 THEN 1 WHEN (3 + 2) THEN 2 WHEN 10 THEN 3 ELSE 0 END * 10) AS f0"+ , eqProp "caseRecordMaybe" caseRecordMaybeX+ "SELECT ALL CASE 5 WHEN 1 THEN 1 WHEN (3 + 2) THEN 2 ELSE NULL END AS f0, \+ \ CASE 5 WHEN 1 THEN 'foo' WHEN (3 + 2) THEN 'bar' ELSE NULL END AS f1" ] _p_cases :: IO ()