relational-query: merge record-width fix of fromMaybe.

This commit is contained in:
Kei Hibino 2019-07-10 03:52:57 +09:00
commit dab5012752
4 changed files with 22 additions and 3 deletions

View File

@ -1,5 +1,9 @@
<!-- -*- Markdown -*- -->
## 0.12.2.2
- bugfix. fix record width of fromMaybe.
## 0.12.2.1
- fix changelog.

View File

@ -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

View File

@ -97,7 +97,7 @@ import Database.Relational.Internal.ContextType (Flat, Exists, OverWindow)
import Database.Relational.Internal.String
(StringSQL, stringSQL, showStringSQL, rowStringSQL)
import Database.Relational.Typed.Record
(Record, Predicate, recordColumns, RecordList)
(Record, Predicate, recordColumns, RecordList, untypeRecord)
import qualified Database.Relational.Typed.Record as Record
import Database.Relational.Pure ()
@ -313,7 +313,7 @@ negate' = unsafeFlatUniOp $ SQL.word "-"
unsafeCastProjectable :: SqlContext c
=> Record c a -> Record c b
unsafeCastProjectable = unsafeProjectSql' . rowStringSQL . recordColumns
unsafeCastProjectable = Record.record . untypeRecord
-- | Number fromIntegral uni-operator.
fromIntegral' :: (SqlContext c, Integral a, Num b)

View File

@ -415,6 +415,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
@ -439,6 +448,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