Skip to content

Commit 1c4bf16

Browse files
committed
column inserts only
1 parent e711c7c commit 1c4bf16

File tree

1 file changed

+6
-16
lines changed
  • coderd/database/dbtestutil

1 file changed

+6
-16
lines changed

coderd/database/dbtestutil/db.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ func pgDump(dbURL string) ([]byte, error) {
159159
"pg_dump",
160160
dbURL,
161161
"--data-only",
162+
"--column-inserts",
162163
"--no-comments",
163164
"--no-privileges",
164165
"--no-publication",
@@ -187,24 +188,13 @@ func filterDump(dump []byte) []byte {
187188
lines := bytes.Split(dump, []byte{'\n'})
188189
var buf bytes.Buffer
189190
for _, line := range lines {
190-
// Skip blank lines
191-
if len(line) == 0 {
191+
// We dump in column-insert format, so these are the only lines
192+
// we care about
193+
if !bytes.HasPrefix(line, []byte("INSERT")) {
192194
continue
193195
}
194-
// Skip comments
195-
if bytes.HasPrefix(line, []byte("--")) {
196-
continue
197-
}
198-
// Skip SELECT or SET statements
199-
if bytes.HasPrefix(line, []byte("SELECT")) {
200-
continue
201-
}
202-
if bytes.HasPrefix(line, []byte("SET")) {
203-
continue
204-
}
205-
206-
buf.Write(line)
207-
buf.WriteRune('\n')
196+
_, _ = buf.Write(line)
197+
_, _ = buf.WriteRune('\n')
208198
}
209199
return buf.Bytes()
210200
}

0 commit comments

Comments
 (0)