Skip to content

Commit 7fbfb39

Browse files
fix query build when no query args are provided
1 parent ddbae95 commit 7fbfb39

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cmd/eywagen/eywatest/eywa_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ import (
1010
"github.com/stretchr/testify/assert"
1111
)
1212

13+
func TestSelectQuerySimple(t *testing.T) {
14+
q := eywa.Get[testTable]().Select(testTable_Name)
15+
16+
expected := `query get_test_table {
17+
test_table {
18+
name
19+
}
20+
}`
21+
assert.Equal(t, expected, q.Query())
22+
}
1323
func TestSelectQuery(t *testing.T) {
1424
age := 10
1525
q := eywa.Get[testTable]().Limit(2).Offset(1).DistinctOn(testTable_Name).OrderBy(

query_arg.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ func (qa queryArgs[M]) MarshalGQL() string {
2828
args = appendArg(args, qa.object)
2929
args = appendArg(args, qa.onConflict)
3030

31+
if len(args) == 0 {
32+
return ""
33+
}
3134
return fmt.Sprintf("(%s)", strings.Join(args, ", "))
3235
}
3336

0 commit comments

Comments
 (0)