graphql-engine/server/src-lib/Hasura/Backends/MSSQL/SQL/Value.hs
Philip Lykke Carlsen 79a80c3f0a MSSQL: Validate variables in subscriptions (close #1210)
GitOrigin-RevId: 5888621dfe44f5f710c2431515114ce0e8864e61
2021-06-08 03:51:15 +00:00

24 lines
997 B
Haskell

module Hasura.Backends.MSSQL.SQL.Value (txtEncodedColVal) where
import Hasura.Prelude
import qualified Database.ODBC.SQLServer as ODBC
import Hasura.GraphQL.Execute.LiveQuery.Plan ()
import qualified Hasura.RQL.Types.Column as RQL
import Data.Text.Encoding (decodeUtf8)
import Hasura.Backends.MSSQL.Types.Internal (Expression (..), Value)
import Hasura.SQL.Backend
import Hasura.SQL.Types (toSQLTxt)
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 $ toSQLTxt $ ValueExpression val
txtEncodedColVal :: RQL.ColumnValue 'MSSQL -> TxtEncodedVal
txtEncodedColVal = txtEncodedVal . RQL.cvValue