Skip to content

Commit

Permalink
chore: add changelog + small improvements to #183
Browse files Browse the repository at this point in the history
  • Loading branch information
andreynering committed May 25, 2024
1 parent e867d65 commit b6a9478
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

- Add `OVERRIDING SYSTEM VALUE` for `INSERT` statements on PostgreSQL
([#183](https://github.com/go-testfixtures/testfixtures/pull/183) by @amakmurr).

## v3.10.0 - 2024-02-17

- Fix usage with Microsoft SQL Server when the database is configured with a
Expand Down
16 changes: 6 additions & 10 deletions postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,7 @@ func (h *postgreSQL) buildInsertSQL(q queryable, tableName string, columns, valu
}
}

return fmt.Sprintf(
"INSERT INTO %s (%s) VALUES (%s)",
tableName,
strings.Join(columns, ", "),
strings.Join(values, ", "),
), nil
return h.baseHelper.buildInsertSQL(q, tableName, columns, values)
}

func (h *postgreSQL) tableHasIdentityColumn(q queryable, tableName string) (bool, error) {
Expand All @@ -437,13 +432,14 @@ func (h *postgreSQL) tableHasIdentityColumn(q queryable, tableName string) (bool
tableName = parts[1][1 : len(parts[1])-1]
}

query := fmt.Sprintf(`
query := `
SELECT COUNT(*) AS count
FROM information_schema.columns
WHERE table_name = '%s' AND is_identity = 'YES'
`, tableName)
WHERE table_name = $1
AND is_identity = 'YES'
`
var count int
if err := q.QueryRow(query).Scan(&count); err != nil {
if err := q.QueryRow(query, tableName).Scan(&count); err != nil {
return false, err
}

Expand Down

0 comments on commit b6a9478

Please sign in to comment.