File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
engine/internal/schema/diff Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ func detectNodeType(node *pg_query.Node) []*pg_query.Node {
5656 fmt .Println ("Select Type" )
5757 }
5858
59- return []* pg_query.Node {node }
59+ return wrapTransaction ( []* pg_query.Node {node })
6060}
6161
6262// IndexStmt processes index statement.
Original file line number Diff line number Diff line change @@ -22,9 +22,9 @@ ALTER TABLE pgbench_accounts
2222 ADD COLUMN test integer NOT NULL DEFAULT 0;
2323`
2424
25- const expectedTpl = `CREATE UNIQUE INDEX CONCURRENTLY title_idx ON films USING btree (title);
25+ const expectedTpl = `BEGIN; CREATE UNIQUE INDEX CONCURRENTLY title_idx ON films USING btree (title); COMMIT ;
2626
27- DROP INDEX CONCURRENTLY title_idx;
27+ BEGIN; DROP INDEX CONCURRENTLY title_idx; COMMIT ;
2828
2929BEGIN; ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5) NOT VALID; COMMIT;
3030BEGIN; ALTER TABLE distributors VALIDATE CONSTRAINT zipchk; COMMIT;
Original file line number Diff line number Diff line change 1+ package diff
2+
3+ import (
4+ "testing"
5+
6+ pg_query "github.com/pganalyze/pg_query_go/v2"
7+ "github.com/stretchr/testify/require"
8+ )
9+
10+ func TestMakeFuncHelpers (t * testing.T ) {
11+ t .Run ("begin transaction statement" , func (t * testing.T ) {
12+ beginStmt := makeBeginTransactionStmt ()
13+
14+ transactionStmt := beginStmt .GetTransactionStmt ()
15+ require .NotNil (t , transactionStmt )
16+ require .Equal (t , pg_query .TransactionStmtKind_TRANS_STMT_BEGIN , transactionStmt .GetKind ())
17+ })
18+
19+ t .Run ("commit transaction statement" , func (t * testing.T ) {
20+ commitStmt := makeCommitTransactionStmt ()
21+
22+ transactionStmt := commitStmt .GetTransactionStmt ()
23+ require .NotNil (t , transactionStmt )
24+ require .Equal (t , pg_query .TransactionStmtKind_TRANS_STMT_COMMIT , transactionStmt .GetKind ())
25+ })
26+ }
You can’t perform that action at this time.
0 commit comments