Skip to content

Add support for built-in range types #32

@nmdanny

Description

@nmdanny

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions