2022-01-11 01:54:51 +03:00
|
|
|
-- | 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.
|
2021-06-08 06:50:24 +03:00
|
|
|
module Hasura.Backends.MSSQL.SQL.Value (txtEncodedColVal) where
|
2021-04-20 19:57:14 +03:00
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
import Data.Text.Encoding (decodeUtf8)
|
|
|
|
import Data.Text.Extended
|
|
|
|
import Database.ODBC.SQLServer qualified as ODBC
|
2022-03-21 13:39:49 +03:00
|
|
|
import Hasura.GraphQL.Execute.Subscription.Plan ()
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.RQL.Types.Column qualified as RQL
|
|
|
|
import Hasura.SQL.Backend
|
|
|
|
import Hasura.SQL.Value (TxtEncodedVal (..))
|
2021-06-15 18:05:41 +03:00
|
|
|
|
2022-04-26 16:47:30 +03:00
|
|
|
txtEncodedVal :: ODBC.Value -> TxtEncodedVal
|
2021-09-24 01:56:37 +03:00
|
|
|
txtEncodedVal ODBC.NullValue = TENull
|
2021-05-10 13:17:54 +03:00
|
|
|
txtEncodedVal (ODBC.ByteStringValue b) = TELit $ decodeUtf8 b
|
2021-09-24 01:56:37 +03:00
|
|
|
txtEncodedVal (ODBC.TextValue t) = TELit t
|
|
|
|
txtEncodedVal val = TELit $ toTxt $ ODBC.toSql val
|
2021-04-20 19:57:14 +03:00
|
|
|
|
2021-06-08 06:50:24 +03:00
|
|
|
txtEncodedColVal :: RQL.ColumnValue 'MSSQL -> TxtEncodedVal
|
|
|
|
txtEncodedColVal = txtEncodedVal . RQL.cvValue
|