File tree 1 file changed +7
-8
lines changed
coderd/database/dbtestutil
1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -197,16 +197,15 @@ func pgDump(dbURL string) ([]byte, error) {
197
197
return stdout .Bytes (), nil
198
198
}
199
199
200
+ // Unfortunately, some insert expressions span multiple lines.
201
+ // The below may be over-permissive but better that than truncating data.
202
+ var insertExpr = regexp .MustCompile (`(?s)\bINSERT[^;]+;` )
203
+
200
204
func filterDump (dump []byte ) []byte {
201
- lines := bytes .Split (dump , []byte {'\n' })
202
205
var buf bytes.Buffer
203
- for _ , line := range lines {
204
- // We dump in column-insert format, so these are the only lines
205
- // we care about
206
- if ! bytes .HasPrefix (line , []byte ("INSERT" )) {
207
- continue
208
- }
209
- _ , _ = buf .Write (line )
206
+ matches := insertExpr .FindAll (dump , - 1 )
207
+ for _ , m := range matches {
208
+ _ , _ = buf .Write (m )
210
209
_ , _ = buf .WriteRune ('\n' )
211
210
}
212
211
return buf .Bytes ()
You can’t perform that action at this time.
0 commit comments