Skip to content

Commit

Permalink
eywagen: fix relationship field name
Browse files Browse the repository at this point in the history
  • Loading branch information
imperfect-fourth committed Sep 15, 2024
1 parent 0a34789 commit 1ac3a71
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 2 additions & 3 deletions cmd/eywagen/eywatest/eywa_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,13 @@ func testTable_customVar[T interface{eywa.JSONValue | eywa.JSONBValue;eywa.Typed
}

func testTable_testTable2(subField eywa.ModelFieldName[testTable2], subFields ...eywa.ModelFieldName[testTable2]) eywa.ModelFieldName[testTable] {
buf := bytes.NewBuffer([]byte((new(testTable2)).ModelName()))
buf.WriteString(" {")
buf := bytes.NewBuffer([]byte("test_table2 {\n"))
buf.WriteString(string(subField))
for _, f := range subFields {
buf.WriteString("\n")
buf.WriteString(string(f))
}
buf.WriteString("}")
buf.WriteString("\n}")
return eywa.ModelFieldName[testTable](buf.String())
}
const testTable_JsonBCol eywa.ModelFieldName[testTable] = "jsonb_col"
Expand Down
4 changes: 3 additions & 1 deletion cmd/eywagen/eywatest/eywa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ func TestRelationshipSelectQuery(t *testing.T) {

expected := `query get_test_table {
test_table(limit: 2, offset: 1, distinct_on: name, where: {_or: [{name: {_eq: "abcd"}}, {age: {_eq: 10}}]}, order_by: {name: desc}) {
test_table2 {id}
test_table2 {
id
}
name
}
}`
Expand Down
2 changes: 1 addition & 1 deletion cmd/eywagen/eywatest/eywatest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type testTable struct {
ID int `json:"id,omitempty"`
iD int32 `json:"idd,omitempty"`
custom *customType `json:"custom"`
testTable2 *testTable2 `json:"testTable2"`
testTable2 *testTable2 `json:"test_table2"`
JsonBCol jsonbcol `json:"jsonb_col"`
RR R `json:"r"`
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/eywagen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ func %sVar[T interface{%s;eywa.TypedValue}](val %s) eywa.ModelField[%s] {

modelRelationshipNameFunc = `
func %s(subField eywa.ModelFieldName[%s], subFields ...eywa.ModelFieldName[%s]) eywa.ModelFieldName[%s] {
buf := bytes.NewBuffer([]byte((new(%s)).ModelName()))
buf.WriteString(" {")
buf := bytes.NewBuffer([]byte("%s {\n"))
buf.WriteString(string(subField))
for _, f := range subFields {
buf.WriteString("\n")
buf.WriteString(string(f))
}
buf.WriteString("}")
buf.WriteString("\n}")
return eywa.ModelFieldName[%s](buf.String())
}
`
Expand Down

0 comments on commit 1ac3a71

Please sign in to comment.