mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-20 22:11:45 +03:00
ea5c92acae
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8876 GitOrigin-RevId: abfc18eeef96a1f3593bfe823adab4d161161333
25 lines
946 B
Haskell
25 lines
946 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.GraphQL.Execute.Subscription.Plan ()
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.Types.BackendType
|
|
import Hasura.RQL.Types.Column qualified as RQL
|
|
import Hasura.RQL.Types.Metadata.Instances ()
|
|
import Hasura.SQL.Value (TxtEncodedVal (..))
|
|
|
|
txtEncodedVal :: ODBC.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
|