Skip to content

Commit 926bf44

Browse files
committed
Added support for converting PGInt4 to Int32
(This is first part of tomjaguarpaw#110.)
1 parent f7899b5 commit 926bf44

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Opaleye/Constant.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ instance D.Default Constant LT.Text (Column T.PGText) where
5454
instance D.Default Constant Int (Column T.PGInt4) where
5555
def = Constant T.pgInt4
5656

57+
instance D.Default Constant Int.Int32 (Column T.PGInt4) where
58+
def = Constant $ T.pgInt4 . fromIntegral
59+
5760
instance D.Default Constant Int.Int64 (Column T.PGInt8) where
5861
def = Constant T.pgInt8
5962

src/Opaleye/Internal/RunQuery.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import qualified Data.ByteString.Lazy as LBS
3333
import qualified Data.Time as Time
3434
import qualified Data.String as String
3535
import Data.UUID (UUID)
36-
import GHC.Int (Int64)
36+
import GHC.Int (Int32, Int64)
3737

3838
-- { Only needed for annoying postgresql-simple patch below
3939

@@ -125,6 +125,9 @@ class QueryRunnerColumnDefault pgType haskellType where
125125
instance QueryRunnerColumnDefault T.PGInt4 Int where
126126
queryRunnerColumnDefault = fieldQueryRunnerColumn
127127

128+
instance QueryRunnerColumnDefault T.PGInt4 Int32 where
129+
queryRunnerColumnDefault = fieldQueryRunnerColumn
130+
128131
instance QueryRunnerColumnDefault T.PGInt8 Int64 where
129132
queryRunnerColumnDefault = fieldQueryRunnerColumn
130133

0 commit comments

Comments
 (0)