Skip to content

Commit

Permalink
fix(tests/postgres-sink): new query generation format
Browse files Browse the repository at this point in the history
  • Loading branch information
le-vlad committed Feb 25, 2024
1 parent ca128c7 commit 254bd52
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion internal/sinks/postgres/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func generateCreateTableStatement(table string, columns []schema.Column) string
func generateBatchInsertStatement(table schema.StreamSchema) string {
columnNames := getColumnNames(table.Columns)
valuesPlaceholder := getValuesPlaceholder(len(table.Columns))
fmt.Println(columnNames, fmt.Sprintf("INSERT INTO \"%s\" (%s) VALUES %s;", table.StreamName, columnNames, valuesPlaceholder), valuesPlaceholder)
return fmt.Sprintf("INSERT INTO \"%s\" (%s) VALUES %s;", table.StreamName, columnNames, valuesPlaceholder)
}

Expand Down
6 changes: 3 additions & 3 deletions internal/sinks/postgres/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ var testMessage = message.NewMessage(message.Snapshot, "flights", []byte(`{"mess

func Test_generateBatchInsertStatement(t *testing.T) {
result := generateBatchInsertStatement(testStreamSchema[0])
if result != "INSERT INTO flights (flights_name, id) VALUES ($1, $2 );" {
if result != "INSERT INTO \"flights\" (flights_name, id) VALUES ($1, $2 );" {
t.Fatal("Generated Insert Query is not correct")
}
}

func Test_generateBatchUpdateStatement(t *testing.T) {
result := generateBatchUpdateStatement(testStreamSchema[0])
if result != "UPDATE flights SET flights_name = $1 WHERE id = $2;\n" {
if result != "UPDATE \"flights\" SET flights_name = $1 WHERE id = $2;\n" {
t.Fatal("Generated Update Query is not correct")
}
}

func Test_generateBatchDeleteStatement(t *testing.T) {
result := generateBatchDeleteStatement(testStreamSchema[0])
fmt.Println(result)
if result != "DELETE FROM flights WHERE id = $1;\n" {
if result != "DELETE FROM \"flights\" WHERE id = $1;\n" {
t.Fatal("Generated Update Query is not correct")
}
}
Expand Down

0 comments on commit 254bd52

Please sign in to comment.