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

Hasura.Backends.MSSQL.Execute.Delete

Description

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

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

Synopsis

Documentation

buildDeleteTx :: AnnDel 'MSSQL -> StringifyNumbers -> QueryTagsComment -> TxET QErr IO EncJSON Source #

Converts a Delete IR AST to a transaction of three delete sql statements.

A GraphQL delete mutation does two things:

  1. Deletes rows in a table according to some predicate
  2. (Potentially) returns the deleted 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 deleted rows from the table we are deleting
  2. DELETE FROM with OUTPUT - deletes the rows from the table and inserts the deleted rows to the temporary table from (1)
  3. SELECT - constructs the returning query from the temporary table, including relationships with other tables.