Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for built-in range types #32

Open
nmdanny opened this issue Jun 27, 2017 · 1 comment
Open

Add support for built-in range types #32

nmdanny opened this issue Jun 27, 2017 · 1 comment

Comments

@nmdanny
Copy link

nmdanny commented Jun 27, 2017

Tisch doesn't seem to have support for range types

I'm not versed in Tisch's internals, but adding the following code:

import           Data.Time               (Day, LocalTime, UTCTime)
import           Opaleye.PGTypes         (PGRange)
import           Tisch.Internal.Kol      (PgPrimType (..))

instance PgTyped (PGRange PGTimestamptz) where type PgType (PGRange PGTimestamptz) = PGRange PGTimestamptz
instance PgTyped (PGRange PGTimestamp) where type PgType (PGRange PGTimestamp) = PGRange PGTimestamp
instance PgTyped (PGRange (PGNumeric s)) where type PgType (PGRange (PGNumeric s)) = PGRange (PGNumeric s)
instance PgTyped (PGRange PGInt4) where type PgType (PGRange PGInt4) = PGRange PGInt4
instance PgTyped (PGRange PGInt8) where type PgType (PGRange PGInt8) = PGRange PGInt8
instance PgTyped (PGRange PGDate) where type PgType (PGRange PGDate) = PGRange PGDate

instance PgPrimType (PGRange PGTimestamptz) where pgPrimTypeName _ = "tstzrange"
instance PgPrimType (PGRange PGTimestamp) where pgPrimTypeName _ = "tsrange"
instance PgPrimType (PGRange (PGNumeric s)) where pgPrimTypeName _ = "numrange"
instance PgPrimType (PGRange PGInt4) where pgPrimTypeName _ = "int4range"
instance PgPrimType (PGRange PGInt8) where pgPrimTypeName _ = "int8range"
instance PgPrimType (PGRange PGDate) where pgPrimTypeName _ = "daterange"

seems to make the following column compile:

'Column "duration" 'WD 'RN (PGRange PGTimestamptz) (PGRange UTCTime)

(still haven't tested the above code)

@k0001
Copy link
Owner

k0001 commented Jul 6, 2017

Hey, thanks for this. It looks about right :) I'll try and make the change soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants