Skip to content

Commit

Permalink
add showSqlTypeWithSchema for types in a schema
Browse files Browse the repository at this point in the history
- similar to enumMapperWithSchema
- enums needs an instance of IsSqlType if used with an array
- enums can have a schema
  • Loading branch information
stevemao committed Apr 8, 2024
1 parent f0718ce commit fc8103e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Opaleye/Internal/PGTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import qualified Data.Text.Lazy.Encoding as LTextEncoding
import qualified Data.ByteString as SByteString
import qualified Data.ByteString.Lazy as LByteString
import qualified Data.Time.Format.ISO8601.Compat as Time
import Text.PrettyPrint.HughesPJ ((<>), doubleQuotes, render, text)
import Prelude hiding ((<>))

unsafePgFormatTime :: Time.ISO8601 t => HPQ.Name -> t -> Field c
unsafePgFormatTime typeName = castToType typeName . format
Expand All @@ -37,5 +39,8 @@ lazyDecodeUtf8 = LText.unpack . LTextEncoding.decodeUtf8

class IsSqlType sqlType where

Check warning on line 40 in src/Opaleye/Internal/PGTypes.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 9.8)

• The MINIMAL pragma does not require:

Check warning on line 40 in src/Opaleye/Internal/PGTypes.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 9.0)

• The MINIMAL pragma does not require:

Check warning on line 40 in src/Opaleye/Internal/PGTypes.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 8.8)

• The MINIMAL pragma does not require:

Check warning on line 40 in src/Opaleye/Internal/PGTypes.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 9.2)

• The MINIMAL pragma does not require:

Check warning on line 40 in src/Opaleye/Internal/PGTypes.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 9.6)

• The MINIMAL pragma does not require:

Check warning on line 40 in src/Opaleye/Internal/PGTypes.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 9.4)

• The MINIMAL pragma does not require:

Check warning on line 40 in src/Opaleye/Internal/PGTypes.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 8.10)

• The MINIMAL pragma does not require:
showSqlType :: proxy sqlType -> String
showSqlType sqlType = render (doubleQuotes (text schema) <> text "." <> doubleQuotes (text type_))
where (schema, type_) = showSqlTypeWithSchema sqlType
showSqlTypeWithSchema :: proxy sqlType -> (String, String)

{-# MINIMAL showSqlType #-}
{-# MINIMAL showSqlType | showSqlTypeWithSchema #-}
2 changes: 1 addition & 1 deletion src/Opaleye/SqlTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module Opaleye.SqlTypes (
SqlUuid,
SqlBytea,
-- * @IsSqlType@
P.IsSqlType(P.showSqlType),
P.IsSqlType(P.showSqlType, P.showSqlTypeWithSchema),
) where

import qualified Opaleye.Field as F
Expand Down

0 comments on commit fc8103e

Please sign in to comment.