Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ast_helpers.raw_transaction #10

Merged
merged 2 commits into from
Jun 20, 2022

Conversation

fljdin
Copy link
Contributor

@fljdin fljdin commented Jun 20, 2022

Closes #7

  • Completes the deparser.transaction_stmt() method to handle options for BEGIN or START TRANSACTION
  • Adds a new helper to create a bunch of statements, inside a transaction block:
SELECT unnest(deparser.expressions_array(ast_helpers.raw_transaction(
  v_stmts := to_jsonb(ARRAY[
    ast.raw_stmt(
      v_stmt := ast.select_stmt(
        v_op := 'SETOP_NONE',
        v_targetList := to_jsonb(ARRAY[
          ast.res_target(v_val := ast.a_const(v_val := ast.integer(1)))
        ])
      ),
      v_stmt_len := 1
    )
  ]),
  v_isolation_level := 'REPEATABLE READ',
  v_deferrable := true
))) as transactions;
                   transactions                    
---------------------------------------------------
 BEGIN ISOLATION LEVEL REPEATABLE READ DEFERRABLE;
 SELECT 1;
 COMMIT;

@pyramation pyramation merged commit 1a848c7 into launchql:master Jun 20, 2022
@pyramation
Copy link
Collaborator

amazing work! thanks for including tests, this is totally awesome @fljdin :)

@fljdin fljdin deleted the 7-new-helper-RawTransaction branch June 30, 2022 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle multiple statements in a transaction
2 participants