File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -7,11 +7,12 @@ module Database.Postgres.SqlValue
77import Prelude
88import Data.Enum (fromEnum )
99import Data.Int (toNumber )
10- import Data.Maybe (Maybe (..) )
10+ import Data.Maybe (Maybe )
1111import Data.Date (year , month , day )
1212import Data.DateTime (DateTime (DateTime))
1313import Data.Time (hour , minute , second )
1414import Unsafe.Coerce (unsafeCoerce )
15+ import Data.Nullable (toNullable )
1516
1617foreign import data SqlValue :: *
1718
@@ -28,8 +29,7 @@ instance isSqlValueInt :: IsSqlValue Int where
2829 toSql = unsafeCoerce <<< toNumber
2930
3031instance isSqlValueMaybe :: (IsSqlValue a ) => IsSqlValue (Maybe a ) where
31- toSql Nothing = nullSqlValue
32- toSql (Just x) = toSql x
32+ toSql = unsafeCoerce <<< toNullable <<< (toSql <$> _)
3333
3434instance isSqlValueDateTime :: IsSqlValue DateTime where
3535 toSql = toSql <<< format
@@ -45,5 +45,3 @@ instance isSqlValueDateTime :: IsSqlValue DateTime where
4545 zeroPad :: Int -> String
4646 zeroPad i | i < 10 = " 0" <> (show i)
4747 zeroPad i = show i
48-
49- foreign import nullSqlValue :: SqlValue
You can’t perform that action at this time.
0 commit comments