Skip to content

Commit

Permalink
Support writes to Postgres with pgx driver (#28521)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaojeling authored Sep 19, 2023
1 parent c7274e9 commit 9c4e8bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdks/go/pkg/beam/io/databaseio/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type valueTemplateGenerator struct {

func (v *valueTemplateGenerator) generate(rowCount int, columnColunt int) string {
switch v.driver {
case "postgres":
case "postgres", "pgx":
// the point is to generate ($1,$2),($3,$4)
valueTemplates := make([]string, rowCount)
for i := 0; i < rowCount; i++ {
Expand Down
6 changes: 6 additions & 0 deletions sdks/go/pkg/beam/io/databaseio/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ func TestValueTemplateGenerator_generate(t *testing.T) {
columnCount: 10,
expected: "",
},
{
generator: &valueTemplateGenerator{"pgx"},
rowCount: 4,
columnCount: 3,
expected: "($1,$2,$3),($4,$5,$6),($7,$8,$9),($10,$11,$12)",
},
{
generator: &valueTemplateGenerator{"mysql"},
rowCount: 4,
Expand Down

0 comments on commit 9c4e8bf

Please sign in to comment.