-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1111 from rfarrjr/master
fix(pgdialect): postgres syntax errors for pointers and slices #877
- Loading branch information
Showing
7 changed files
with
251 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package pgdialect | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/uptrace/bun/schema" | ||
) | ||
|
||
func ptr[T any](v T) *T { | ||
return &v | ||
} | ||
|
||
func TestArrayAppend(t *testing.T) { | ||
tcases := []struct { | ||
input interface{} | ||
out string | ||
}{ | ||
{ | ||
input: []byte{1, 2}, | ||
out: `'{1,2}'`, | ||
}, | ||
{ | ||
input: []*byte{ptr(byte(1)), ptr(byte(2))}, | ||
out: `'{1,2}'`, | ||
}, | ||
{ | ||
input: []int{1, 2}, | ||
out: `'{1,2}'`, | ||
}, | ||
{ | ||
input: []*int{ptr(1), ptr(2)}, | ||
out: `'{1,2}'`, | ||
}, | ||
{ | ||
input: []string{"foo", "bar"}, | ||
out: `'{"foo","bar"}'`, | ||
}, | ||
{ | ||
input: []*string{ptr("foo"), ptr("bar")}, | ||
out: `'{"foo","bar"}'`, | ||
}, | ||
} | ||
|
||
for _, tcase := range tcases { | ||
out, err := Array(tcase.input).AppendQuery(schema.NewFormatter(New()), []byte{}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if string(out) != tcase.out { | ||
t.Errorf("expected output to be %s, was %s", tcase.out, string(out)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters