mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 04:51:35 +03:00
57607f5295
[GDC-687]: https://hasurahq.atlassian.net/browse/GDC-687?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [GDC-687]: https://hasurahq.atlassian.net/browse/GDC-687?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7355 GitOrigin-RevId: fa02a83c0c594abe05c1071d0de5054478c32e56
45 lines
1.6 KiB
Haskell
45 lines
1.6 KiB
Haskell
-- | This module defines the translation functions for update mutations.
|
|
module Hasura.Backends.MSSQL.FromIr.Update
|
|
( fromUpdate,
|
|
)
|
|
where
|
|
|
|
import Hasura.Backends.MSSQL.FromIr
|
|
( FromIr,
|
|
NameTemplate (TableTemplate),
|
|
generateAlias,
|
|
)
|
|
import Hasura.Backends.MSSQL.FromIr.Constants (tempTableNameUpdated)
|
|
import Hasura.Backends.MSSQL.FromIr.Expression (fromGBoolExp)
|
|
import Hasura.Backends.MSSQL.Instances.Types ()
|
|
import Hasura.Backends.MSSQL.Types.Internal
|
|
import Hasura.Backends.MSSQL.Types.Update
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.IR qualified as IR
|
|
import Hasura.RQL.IR.Update.Batch qualified as IR
|
|
import Hasura.RQL.Types.Column qualified as IR
|
|
import Hasura.SQL.Backend
|
|
|
|
fromUpdate :: IR.AnnotatedUpdate 'MSSQL -> FromIr Update
|
|
fromUpdate (IR.AnnotatedUpdateG table updatePermFilter _ (IR.UpdateBatch updateOperations whereClause) _ allColumns _tCase) = do
|
|
tableAlias <- generateAlias (TableTemplate (tableName table))
|
|
runReaderT
|
|
( do
|
|
permissionsFilter <- fromGBoolExp updatePermFilter
|
|
whereExpression <- fromGBoolExp whereClause
|
|
let columnNames = map IR.ciColumn allColumns
|
|
pure
|
|
Update
|
|
{ updateTable =
|
|
Aliased
|
|
{ aliasedAlias = tableAlias,
|
|
aliasedThing = table
|
|
},
|
|
updateSet = updateOperations,
|
|
updateOutput = Output Inserted (map OutputColumn columnNames),
|
|
updateTempTable = TempTable tempTableNameUpdated columnNames,
|
|
updateWhere = Where [permissionsFilter, whereExpression]
|
|
}
|
|
)
|
|
(EntityAlias tableAlias)
|