From 14005723841b9b410aa5801e1b71ecd4952ee236 Mon Sep 17 00:00:00 2001 From: Kei Hibino Date: Wed, 10 Jul 2019 03:39:11 +0900 Subject: [PATCH 1/2] relational-query: bugfix. fix record width of fromMaybe result. --- .../src/Database/Relational/Projectable.hs | 2 +- relational-query/test/sqlsEq.hs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/relational-query/src/Database/Relational/Projectable.hs b/relational-query/src/Database/Relational/Projectable.hs index 438f3d73..c09c3b85 100644 --- a/relational-query/src/Database/Relational/Projectable.hs +++ b/relational-query/src/Database/Relational/Projectable.hs @@ -300,7 +300,7 @@ negate' = unsafeFlatUniOp $ SQL.word "-" unsafeCastProjectable :: SqlContext c => Record c a -> Record c b -unsafeCastProjectable = unsafeProjectSql' . unsafeShowSql' +unsafeCastProjectable = Syntax.record . Syntax.untypeRecord -- | Number fromIntegral uni-operator. fromIntegral' :: (SqlContext c, Integral a, Num b) diff --git a/relational-query/test/sqlsEq.hs b/relational-query/test/sqlsEq.hs index 4044f34a..e0224363 100644 --- a/relational-query/test/sqlsEq.hs +++ b/relational-query/test/sqlsEq.hs @@ -414,6 +414,15 @@ maybeX = relation $ do return $ fromMaybe (value 1) (a ?! intA0') >< b +maybeY :: Relation () (SetA, SetB) +maybeY = relation $ do + a <- queryMaybe setA + b <- query setB + + wheres $ a ?! strA2' .=. b ! mayStrB1' + + return $ fromMaybe (SetA |$| value 1 |*| value "foo" |*| value "var") a >< b + notX :: Relation () (Maybe Bool) notX = relation $ return $ not' valueFalse @@ -438,6 +447,12 @@ uni = "SELECT ALL CASE WHEN (T0.int_a0 IS NULL) THEN 1 ELSE T0.int_a0 END AS f0, \ \ T1.int_b0 AS f1, T1.may_str_b1 AS f2, T1.str_b2 AS f3 \ \ FROM TEST.set_a T0 RIGHT JOIN TEST.set_b T1 ON (0=0) WHERE (T0.str_a2 = T1.may_str_b1)" + , eqProp "fromMaybe record" maybeY + "SELECT ALL CASE WHEN (T0.int_a0 IS NULL) THEN 1 ELSE T0.int_a0 END AS f0, \ + \ CASE WHEN (T0.int_a0 IS NULL) THEN 'foo' ELSE T0.str_a1 END AS f1, \ + \ CASE WHEN (T0.int_a0 IS NULL) THEN 'var' ELSE T0.str_a2 END AS f2, \ + \ T1.int_b0 AS f3, T1.may_str_b1 AS f4, T1.str_b2 AS f5 \ + \ FROM TEST.set_a T0 RIGHT JOIN TEST.set_b T1 ON (0=0) WHERE (T0.str_a2 = T1.may_str_b1)" , eqProp "not" notX "SELECT ALL (NOT (0=1)) AS f0" , eqProp "exists" existsX From e0d044a044409115effc9e254bd4261cb8a3dafc Mon Sep 17 00:00:00 2001 From: Kei Hibino Date: Wed, 10 Jul 2019 03:47:35 +0900 Subject: [PATCH 2/2] relational-query: bump. --- relational-query/ChangeLog.md | 4 ++++ relational-query/relational-query.cabal | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/relational-query/ChangeLog.md b/relational-query/ChangeLog.md index e84d644d..2a39e152 100644 --- a/relational-query/ChangeLog.md +++ b/relational-query/ChangeLog.md @@ -1,5 +1,9 @@ +## 0.12.2.2 + +- bugfix. fix record width of fromMaybe. + ## 0.12.2.1 - fix changelog. diff --git a/relational-query/relational-query.cabal b/relational-query/relational-query.cabal index 5b609482..47b8d1be 100644 --- a/relational-query/relational-query.cabal +++ b/relational-query/relational-query.cabal @@ -1,5 +1,5 @@ name: relational-query -version: 0.12.2.1 +version: 0.12.2.2 synopsis: Typeful, Modular, Relational, algebraic query engine description: This package contiains typeful relation structure and relational-algebraic query building DSL which can