graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.Backends.MSSQL.Execute.Update

Description

Responsible for translating and building an MSSQL execution plan for update mutations.

This module is used by Hasura.Backends.MSSQL.Instances.Execute.

Synopsis

Documentation

buildUpdateTx :: AnnotatedUpdate 'MSSQL -> StringifyNumbers -> QueryTagsComment -> TxET QErr IO EncJSON Source #

Converts an Update IR AST to a transaction of three update sql statements.

A GraphQL update mutation does two things:

  1. Update rows in a table according to some predicate
  2. (Potentially) returns the updated rows (including relationships) as JSON

In order to complete these 2 things we need 3 SQL statements:

  1. SELECT INTO temp_table WHERE false - creates a temporary table with the same schema as the original table in which we'll store the updated rows from the table we are deleting
  2. UPDATE SET FROM with OUTPUT - updates the rows from the table and inserts the updated rows to the temporary table from (1)
  3. SELECT - constructs the returning query from the temporary table, including relationships with other tables.