You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Maybe Int is also an SqlTpye, the following code type checks.
But one of the operand is NULL, the result will be NULL, making the code crash.
test::IOBool
test = withSQLite "test.sqlite"$do
[b] <- query $pure$ just (4::ColsInt) .== literal Nothingpure b
Using Nullable module's operator (?==) will get the proper result type Col s (Maybe Bool).
But the need to correctly use (.==) and (?==) is error-prone.
First thing that comes to my mind, is to add type IsNullable a :: 'Bool to SqlType type class. SqlType (Maybe a) instance will be the only instance to have IsNullable (Maybe a) = 'True, and other instances will have False.Then we could wrap Bool with Maybe when SqlType is IsNullable.
The text was updated successfully, but these errors were encountered:
kamoii
pushed a commit
to kamoii/nelda
that referenced
this issue
Oct 31, 2020
Comparison operators, like
(.==)
, accepts aribtrarySqlType
value.Since
Maybe Int
is also anSqlTpye
, the following code type checks.But one of the operand is
NULL
, the result will beNULL
, making the code crash.Using
Nullable
module's operator(?==)
will get the proper result typeCol s (Maybe Bool)
.But the need to correctly use
(.==)
and(?==)
is error-prone.First thing that comes to my mind, is to add
type IsNullable a :: 'Bool
toSqlType
type class.SqlType (Maybe a)
instance will be the only instance to haveIsNullable (Maybe a) = 'True
, and other instances will haveFalse
.Then we could wrapBool
withMaybe
whenSqlType
isIsNullable
.The text was updated successfully, but these errors were encountered: