Move text operator out of SQL.Types. (#406)

GitOrigin-RevId: 25adad545b302fd1dde25ea0365d492dfcdaa71d
This commit is contained in:
Antoine Leblanc 2021-01-26 12:22:24 +00:00 committed by hasura-bot
parent 6494229f54
commit 62a3bb0d9e
2 changed files with 14 additions and 11 deletions

View File

@ -951,3 +951,13 @@ instance (ToSQL v) => ToSQL (SelectWithG v) where
f (Alias al, q) = toSQL al <~> "AS" <~> parenB (toSQL q)
type SelectWith = SelectWithG CTE
-- local helpers
infixr 6 <+>
(<+>) :: (ToSQL a) => Text -> [a] -> TB.Builder
(<+>) _ [] = mempty
(<+>) kat (x:xs) =
toSQL x <> mconcat [ TB.text kat <> toSQL x' | x' <- xs ]
{-# INLINE (<+>) #-}

View File

@ -1,19 +1,20 @@
module Hasura.SQL.Types
( ToSQL(..)
, toSQLTxt
, (<+>)
, CollectableType(..)
)
where
import Hasura.Prelude
import Hasura.Incremental (Cacheable)
import qualified Text.Builder as TB
import qualified Text.Builder as TB
import Data.Aeson
import Data.Aeson.TH
import Hasura.Incremental (Cacheable)
class ToSQL a where
toSQL :: a -> TB.Builder
@ -27,14 +28,6 @@ instance (ToSQL a) => ToSQL (Maybe a) where
toSQLTxt :: (ToSQL a) => a -> Text
toSQLTxt = TB.run . toSQL
infixr 6 <+>
(<+>) :: (ToSQL a) => Text -> [a] -> TB.Builder
(<+>) _ [] = mempty
(<+>) kat (x:xs) =
toSQL x <> mconcat [ TB.text kat <> toSQL x' | x' <- xs ]
{-# INLINE (<+>) #-}
-- | The type of all Postgres types (i.e. scalars and arrays). This type is parameterized so that
-- we can have both @'CollectableType' 'PGScalarType'@ and @'CollectableType' 'Hasura.RQL.Types.PGColumnType'@, for
-- when we care about the distinction made by 'Hasura.RQL.Types.PGColumnType'. If we ever change