Skip to content

Commit fe20a21

Browse files
committed
fix(transactions): add commit to the wrapper for better performance
1 parent a8bc43a commit fe20a21

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pkg/builder/Global.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ ScriptTransactionWrapper Wraps string in transction for postgresql
5858
*/
5959
func ScriptTransactionWrapper(query string) string {
6060
prefix := "DO $$ BEGIN"
61-
suffix := "END $$ ;"
61+
suffix := "END $$; COMMIT;"
6262
return fmt.Sprintf("%v %v %v", prefix, query, suffix)
6363
}

pkg/builder/Global_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func TestScriptTransactionWrapper(t *testing.T) {
4141
args args
4242
want string
4343
}{
44-
{name: "InbPackageBuildTest1", args: args{query: "SELECT 1;"}, want: "DO $$ BEGIN SELECT 1; END $$ ;"},
45-
{name: "InbPackageBuildTest2", args: args{query: "TRUNCATE TABLE public.test;"}, want: "DO $$ BEGIN TRUNCATE TABLE public.test; END $$ ;"},
44+
{name: "InbPackageBuildTest1", args: args{query: "SELECT 1;"}, want: "DO $$ BEGIN SELECT 1; END $$; COMMIT;"},
45+
{name: "InbPackageBuildTest2", args: args{query: "TRUNCATE TABLE public.test;"}, want: "DO $$ BEGIN TRUNCATE TABLE public.test; END $$; COMMIT;"},
4646
}
4747
for _, tt := range tests {
4848
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)