graphql-engine/server/src-lib/Hasura/Backends/MSSQL/SQL/Value.hs
Antoine Leblanc a805f4d185 server: misc cleanups
https://github.com/hasura/graphql-engine-mono/pull/1553

GitOrigin-RevId: b67dc40e54496ed6ad6c85755cf66745664416f7
2021-06-15 15:06:37 +00:00

26 lines
944 B
Haskell

module Hasura.Backends.MSSQL.SQL.Value (txtEncodedColVal) where
import Hasura.Prelude
import qualified Database.ODBC.SQLServer as ODBC
import Data.Text.Encoding (decodeUtf8)
import Data.Text.Extended
import qualified Hasura.RQL.Types.Column as RQL
import Hasura.Backends.MSSQL.Types.Internal (Value)
import Hasura.GraphQL.Execute.LiveQuery.Plan ()
import Hasura.SQL.Backend
import Hasura.SQL.Value (TxtEncodedVal (..))
txtEncodedVal :: Value -> TxtEncodedVal
txtEncodedVal ODBC.NullValue = TENull
txtEncodedVal (ODBC.ByteStringValue b) = TELit $ decodeUtf8 b
txtEncodedVal (ODBC.TextValue t) = TELit t
txtEncodedVal val = TELit $ toTxt $ ODBC.toSql val
txtEncodedColVal :: RQL.ColumnValue 'MSSQL -> TxtEncodedVal
txtEncodedColVal = txtEncodedVal . RQL.cvValue