graphql-engine/server/src-lib/Hasura/Backends/MSSQL/SQL/Value.hs
Evie Ciobanu 463a303390 server: add MSSQL module haddocks
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3293
GitOrigin-RevId: 3062d5b1f41ce1fb18afc78773a2c947d8765309
2022-01-10 22:55:48 +00:00

25 lines
934 B
Haskell

-- | MSSQL SQL Value
--
-- Provide a function to translate from a column value to its literal (textual)
-- value specific to MSSQL. Used in the 'BackendExecute' instance.
module Hasura.Backends.MSSQL.SQL.Value (txtEncodedColVal) where
import Data.Text.Encoding (decodeUtf8)
import Data.Text.Extended
import Database.ODBC.SQLServer qualified as ODBC
import Hasura.Backends.MSSQL.Types.Internal (Value)
import Hasura.GraphQL.Execute.LiveQuery.Plan ()
import Hasura.Prelude
import Hasura.RQL.Types.Column qualified as RQL
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