diff --git a/cmd/edgeql-go/endtoend_test.go b/cmd/edgeql-go/endtoend_test.go index b50c665..033f041 100644 --- a/cmd/edgeql-go/endtoend_test.go +++ b/cmd/edgeql-go/endtoend_test.go @@ -55,6 +55,11 @@ var tests = []struct { directory: "testdata/pubfuncs", args: []string{"-pubfuncs"}, }, + { + description: "invoke edgeql-go with -pubtypes", + directory: "testdata/pubtypes", + args: []string{"-pubtypes"}, + }, } func TestMain(m *testing.M) { diff --git a/cmd/edgeql-go/main.go b/cmd/edgeql-go/main.go index 5b957f4..7eca640 100644 --- a/cmd/edgeql-go/main.go +++ b/cmd/edgeql-go/main.go @@ -61,6 +61,7 @@ func usage() { type cmdConfig struct { mixedCaps bool pubfuncs bool + pubtypes bool } func main() { @@ -73,11 +74,14 @@ func main() { "to MixedCaps names in go structs") pubfuncs := flag.Bool("pubfuncs", false, "Make generated functions public.") + pubtypes := flag.Bool("pubtypes", false, + "Make generated types public.") flag.Parse() cfg := &cmdConfig{ mixedCaps: *mixedCaps, pubfuncs: *pubfuncs, + pubtypes: *pubtypes, } timer := time.AfterFunc(200*time.Millisecond, func() { diff --git a/cmd/edgeql-go/query.go b/cmd/edgeql-go/query.go index 92c85d5..56230de 100644 --- a/cmd/edgeql-go/query.go +++ b/cmd/edgeql-go/query.go @@ -252,6 +252,9 @@ func queryName(qryFile string, cmdCfg *cmdConfig) string { func typeName(qryFile string, cmdCfg *cmdConfig) string { name := filepath.Base(qryFile) name = strings.TrimSuffix(name, ".edgeql") + if cmdCfg.pubtypes { + return snakeToUpperMixedCase(name) + } return snakeToLowerMixedCase(name) } diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/edgedb.toml b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/edgedb.toml new file mode 100644 index 0000000..c740e72 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/edgedb.toml @@ -0,0 +1,5 @@ +[edgedb] +server-version = "3.3" + +[project] +schema-dir = "somewhere/else" diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/go.mod b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/go.mod new file mode 100644 index 0000000..087c77c --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/go.mod @@ -0,0 +1,13 @@ +module test + +go 1.19 + +require ( + github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect + github.com/edgedb/edgedb-go v0.12.0 // indirect + github.com/xdg/scram v1.0.5 // indirect + github.com/xdg/stringprep v1.0.3 // indirect + golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/go.sum b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/go.sum new file mode 100644 index 0000000..b6b15a7 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/go.sum @@ -0,0 +1,35 @@ +github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d h1:S2NE3iHSwP0XV47EEXL8mWmRdEfGscSJ+7EgePNgt0s= +github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/edgedb/edgedb-go v0.12.0 h1:WQBe/+0kCoccnhsWw+O7cppemsVfy55rAk0EsLrmCHk= +github.com/edgedb/edgedb-go v0.12.0/go.mod h1:O+ZRO2juj+e0PaoK1u2iZmLe7jXko9MlODiHXwSxDYA= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/xdg/scram v1.0.5 h1:TuS0RFmt5Is5qm9Tm2SoD89OPqe4IRiFtyFY4iwWXsw= +github.com/xdg/scram v1.0.5/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v1.0.3 h1:cmL5Enob4W83ti/ZHuZLuKD/xqJfus4fVPwE+/BDm+4= +github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/ignore.go b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/ignore.go new file mode 100644 index 0000000..38dd16d --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/ignore.go @@ -0,0 +1,3 @@ +package main + +func main() {} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/select_scalar.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/select_scalar.edgeql new file mode 100644 index 0000000..ab290eb --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/select_scalar.edgeql @@ -0,0 +1 @@ +select 1; diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/select_scalar_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/select_scalar_edgeql.go.assert new file mode 100644 index 0000000..9c6673c --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/select_scalar_edgeql.go.assert @@ -0,0 +1,53 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package main + +import ( + "context" + _ "embed" + + "github.com/edgedb/edgedb-go" +) + +//go:embed select_scalar.edgeql +var selectScalarCmd string + +// selectScalar +// runs the query found in +// select_scalar.edgeql +func selectScalar( + ctx context.Context, + client *edgedb.Client, +) (int64, error) { + var result int64 + + err := client.QuerySingle( + ctx, + selectScalarCmd, + &result, + ) + + return result, err +} + +// selectScalarJSON +// runs the query found in +// select_scalar.edgeql +// returning the results as json encoded bytes +func selectScalarJSON( + ctx context.Context, + client *edgedb.Client, +) ([]byte, error) { + var result []byte + + err := client.QuerySingleJSON( + ctx, + selectScalarCmd, + &result, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/somewhere/else/migrations/00001.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/somewhere/else/migrations/00001.edgeql new file mode 100644 index 0000000..88bbd87 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project-alternate-schemadir/somewhere/else/migrations/00001.edgeql @@ -0,0 +1,12 @@ +CREATE MIGRATION m1fqtauhtvc2w56wh2676x5g26aye22ghx7b7mtnbfekxpmxmnjx2a + ONTO initial +{ + CREATE TYPE default::Person { + CREATE MULTI LINK friends -> default::Person { + CREATE PROPERTY strength -> std::float64; + }; + CREATE REQUIRED PROPERTY name -> std::str { + CREATE CONSTRAINT std::exclusive; + }; + }; +}; diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project1/edgedb.toml b/cmd/edgeql-go/testdata/pubtypes/test-project1/edgedb.toml new file mode 100644 index 0000000..e69de29 diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project1/go.mod b/cmd/edgeql-go/testdata/pubtypes/test-project1/go.mod new file mode 100644 index 0000000..087c77c --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project1/go.mod @@ -0,0 +1,13 @@ +module test + +go 1.19 + +require ( + github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect + github.com/edgedb/edgedb-go v0.12.0 // indirect + github.com/xdg/scram v1.0.5 // indirect + github.com/xdg/stringprep v1.0.3 // indirect + golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project1/go.sum b/cmd/edgeql-go/testdata/pubtypes/test-project1/go.sum new file mode 100644 index 0000000..b6b15a7 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project1/go.sum @@ -0,0 +1,35 @@ +github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d h1:S2NE3iHSwP0XV47EEXL8mWmRdEfGscSJ+7EgePNgt0s= +github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/edgedb/edgedb-go v0.12.0 h1:WQBe/+0kCoccnhsWw+O7cppemsVfy55rAk0EsLrmCHk= +github.com/edgedb/edgedb-go v0.12.0/go.mod h1:O+ZRO2juj+e0PaoK1u2iZmLe7jXko9MlODiHXwSxDYA= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/xdg/scram v1.0.5 h1:TuS0RFmt5Is5qm9Tm2SoD89OPqe4IRiFtyFY4iwWXsw= +github.com/xdg/scram v1.0.5/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v1.0.3 h1:cmL5Enob4W83ti/ZHuZLuKD/xqJfus4fVPwE+/BDm+4= +github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project1/ignore.go b/cmd/edgeql-go/testdata/pubtypes/test-project1/ignore.go new file mode 100644 index 0000000..38dd16d --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project1/ignore.go @@ -0,0 +1,3 @@ +package main + +func main() {} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project1/select_scalar.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project1/select_scalar.edgeql new file mode 100644 index 0000000..ab290eb --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project1/select_scalar.edgeql @@ -0,0 +1 @@ +select 1; diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project1/select_scalar_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project1/select_scalar_edgeql.go.assert new file mode 100644 index 0000000..9c6673c --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project1/select_scalar_edgeql.go.assert @@ -0,0 +1,53 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package main + +import ( + "context" + _ "embed" + + "github.com/edgedb/edgedb-go" +) + +//go:embed select_scalar.edgeql +var selectScalarCmd string + +// selectScalar +// runs the query found in +// select_scalar.edgeql +func selectScalar( + ctx context.Context, + client *edgedb.Client, +) (int64, error) { + var result int64 + + err := client.QuerySingle( + ctx, + selectScalarCmd, + &result, + ) + + return result, err +} + +// selectScalarJSON +// runs the query found in +// select_scalar.edgeql +// returning the results as json encoded bytes +func selectScalarJSON( + ctx context.Context, + client *edgedb.Client, +) ([]byte, error) { + var result []byte + + err := client.QuerySingleJSON( + ctx, + selectScalarCmd, + &result, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/argnames/query_one.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/argnames/query_one.edgeql new file mode 100644 index 0000000..129ceda --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/argnames/query_one.edgeql @@ -0,0 +1 @@ +select $arg_name_with_underscores diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/argnames/query_one_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project2/argnames/query_one_edgeql.go.assert new file mode 100644 index 0000000..5db1d0a --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/argnames/query_one_edgeql.go.assert @@ -0,0 +1,61 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package argnames + +import ( + "context" + _ "embed" + + "github.com/edgedb/edgedb-go" +) + +//go:embed query_one.edgeql +var queryOneCmd string + +// queryOne +// runs the query found in +// query_one.edgeql +func queryOne( + ctx context.Context, + client *edgedb.Client, + arg_name_with_underscores int64, +) (int64, error) { + var result int64 + + err := client.QuerySingle( + ctx, + queryOneCmd, + &result, + map[string]interface{}{ + "arg_name_with_underscores": arg_name_with_underscores, + }, + ) + + return result, err +} + +// queryOneJSON +// runs the query found in +// query_one.edgeql +// returning the results as json encoded bytes +func queryOneJSON( + ctx context.Context, + client *edgedb.Client, + arg_name_with_underscores int64, +) ([]byte, error) { + var result []byte + + err := client.QuerySingleJSON( + ctx, + queryOneCmd, + &result, + map[string]interface{}{ + "arg_name_with_underscores": arg_name_with_underscores, + }, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/dbschema/migrations/00001.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/dbschema/migrations/00001.edgeql new file mode 100644 index 0000000..88bbd87 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/dbschema/migrations/00001.edgeql @@ -0,0 +1,12 @@ +CREATE MIGRATION m1fqtauhtvc2w56wh2676x5g26aye22ghx7b7mtnbfekxpmxmnjx2a + ONTO initial +{ + CREATE TYPE default::Person { + CREATE MULTI LINK friends -> default::Person { + CREATE PROPERTY strength -> std::float64; + }; + CREATE REQUIRED PROPERTY name -> std::str { + CREATE CONSTRAINT std::exclusive; + }; + }; +}; diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/edgedb.toml b/cmd/edgeql-go/testdata/pubtypes/test-project2/edgedb.toml new file mode 100644 index 0000000..e69de29 diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/go.mod b/cmd/edgeql-go/testdata/pubtypes/test-project2/go.mod new file mode 100644 index 0000000..087c77c --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/go.mod @@ -0,0 +1,13 @@ +module test + +go 1.19 + +require ( + github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect + github.com/edgedb/edgedb-go v0.12.0 // indirect + github.com/xdg/scram v1.0.5 // indirect + github.com/xdg/stringprep v1.0.3 // indirect + golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/go.sum b/cmd/edgeql-go/testdata/pubtypes/test-project2/go.sum new file mode 100644 index 0000000..b6b15a7 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/go.sum @@ -0,0 +1,35 @@ +github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d h1:S2NE3iHSwP0XV47EEXL8mWmRdEfGscSJ+7EgePNgt0s= +github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/edgedb/edgedb-go v0.12.0 h1:WQBe/+0kCoccnhsWw+O7cppemsVfy55rAk0EsLrmCHk= +github.com/edgedb/edgedb-go v0.12.0/go.mod h1:O+ZRO2juj+e0PaoK1u2iZmLe7jXko9MlODiHXwSxDYA= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/xdg/scram v1.0.5 h1:TuS0RFmt5Is5qm9Tm2SoD89OPqe4IRiFtyFY4iwWXsw= +github.com/xdg/scram v1.0.5/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v1.0.3 h1:cmL5Enob4W83ti/ZHuZLuKD/xqJfus4fVPwE+/BDm+4= +github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/ignore.go b/cmd/edgeql-go/testdata/pubtypes/test-project2/ignore.go new file mode 100644 index 0000000..38dd16d --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/ignore.go @@ -0,0 +1,3 @@ +package main + +func main() {} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/object/ignore.go b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/ignore.go new file mode 100644 index 0000000..722bd01 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/ignore.go @@ -0,0 +1 @@ +package object diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_link_prop.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_link_prop.edgeql new file mode 100644 index 0000000..bd21835 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_link_prop.edgeql @@ -0,0 +1,17 @@ +create type Person { + create required property Name -> str { + create constraint exclusive; + }; + create multi link Friends -> Person { + create property Strength -> float64; + } +}; + +select Person { + Name, + Friends: { + Name, + @Strength, + }, +} + diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_link_prop_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_link_prop_edgeql.go.assert new file mode 100644 index 0000000..47527eb --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_link_prop_edgeql.go.assert @@ -0,0 +1,69 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package object + +import ( + "context" + _ "embed" + + "github.com/edgedb/edgedb-go" +) + +//go:embed select_link_prop.edgeql +var selectLinkPropCmd string + +// SelectLinkPropResult +// is part of the return type for +// selectLinkProp() +type SelectLinkPropResult struct { + Name string `edgedb:"Name"` + Friends []SelectLinkPropResultFriendsItem `edgedb:"Friends"` +} + +// SelectLinkPropResultFriendsItem +// is part of the return type for +// selectLinkProp() +type SelectLinkPropResultFriendsItem struct { + Name string `edgedb:"Name"` + Strength edgedb.OptionalFloat64 `edgedb:"Strength"` +} + +// selectLinkProp +// runs the query found in +// select_link_prop.edgeql +func selectLinkProp( + ctx context.Context, + client *edgedb.Client, +) ([]SelectLinkPropResult, error) { + var result []SelectLinkPropResult + + err := client.Query( + ctx, + selectLinkPropCmd, + &result, + ) + + return result, err +} + +// selectLinkPropJSON +// runs the query found in +// select_link_prop.edgeql +// returning the results as json encoded bytes +func selectLinkPropJSON( + ctx context.Context, + client *edgedb.Client, +) ([]byte, error) { + var result []byte + + err := client.QueryJSON( + ctx, + selectLinkPropCmd, + &result, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_object.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_object.edgeql new file mode 100644 index 0000000..839f6b7 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_object.edgeql @@ -0,0 +1,9 @@ +select schema::Function { + Name := .name, + Language := .language, + Params := .params { + Name := .name, + Default := .default, + } +} +limit 1; diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_object_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_object_edgeql.go.assert new file mode 100644 index 0000000..f11a454 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_object_edgeql.go.assert @@ -0,0 +1,71 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package object + +import ( + "context" + _ "embed" + + "github.com/edgedb/edgedb-go" +) + +//go:embed select_object.edgeql +var selectObjectCmd string + +// SelectObjectResult +// is part of the return type for +// selectObject() +type SelectObjectResult struct { + edgedb.Optional + Name string `edgedb:"Name"` + Language string `edgedb:"Language"` + Params []SelectObjectResultParamsItem `edgedb:"Params"` +} + +// SelectObjectResultParamsItem +// is part of the return type for +// selectObject() +type SelectObjectResultParamsItem struct { + Name string `edgedb:"Name"` + Default edgedb.OptionalStr `edgedb:"Default"` +} + +// selectObject +// runs the query found in +// select_object.edgeql +func selectObject( + ctx context.Context, + client *edgedb.Client, +) (SelectObjectResult, error) { + var result SelectObjectResult + + err := client.QuerySingle( + ctx, + selectObjectCmd, + &result, + ) + + return result, err +} + +// selectObjectJSON +// runs the query found in +// select_object.edgeql +// returning the results as json encoded bytes +func selectObjectJSON( + ctx context.Context, + client *edgedb.Client, +) ([]byte, error) { + var result []byte + + err := client.QuerySingleJSON( + ctx, + selectObjectCmd, + &result, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_objects.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_objects.edgeql new file mode 100644 index 0000000..cea3bc3 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_objects.edgeql @@ -0,0 +1,8 @@ +select schema::Function { + Name := .name, + Language := .language, + Params := .params { + Name := .name, + Default := .default, + } +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_objects_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_objects_edgeql.go.assert new file mode 100644 index 0000000..d8a00cf --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/object/select_objects_edgeql.go.assert @@ -0,0 +1,70 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package object + +import ( + "context" + _ "embed" + + "github.com/edgedb/edgedb-go" +) + +//go:embed select_objects.edgeql +var selectObjectsCmd string + +// SelectObjectsResult +// is part of the return type for +// selectObjects() +type SelectObjectsResult struct { + Name string `edgedb:"Name"` + Language string `edgedb:"Language"` + Params []SelectObjectsResultParamsItem `edgedb:"Params"` +} + +// SelectObjectsResultParamsItem +// is part of the return type for +// selectObjects() +type SelectObjectsResultParamsItem struct { + Name string `edgedb:"Name"` + Default edgedb.OptionalStr `edgedb:"Default"` +} + +// selectObjects +// runs the query found in +// select_objects.edgeql +func selectObjects( + ctx context.Context, + client *edgedb.Client, +) ([]SelectObjectsResult, error) { + var result []SelectObjectsResult + + err := client.Query( + ctx, + selectObjectsCmd, + &result, + ) + + return result, err +} + +// selectObjectsJSON +// runs the query found in +// select_objects.edgeql +// returning the results as json encoded bytes +func selectObjectsJSON( + ctx context.Context, + client *edgedb.Client, +) ([]byte, error) { + var result []byte + + err := client.QueryJSON( + ctx, + selectObjectsCmd, + &result, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/ignore.go b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/ignore.go new file mode 100644 index 0000000..8afb063 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/ignore.go @@ -0,0 +1 @@ +package scalar diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_array.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_array.edgeql new file mode 100644 index 0000000..b14fe29 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_array.edgeql @@ -0,0 +1 @@ +select ['a', 'b', 'c']; diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_array_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_array_edgeql.go.assert new file mode 100644 index 0000000..4ab74b9 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_array_edgeql.go.assert @@ -0,0 +1,53 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package scalar + +import ( + "context" + _ "embed" + + "github.com/edgedb/edgedb-go" +) + +//go:embed select_array.edgeql +var selectArrayCmd string + +// selectArray +// runs the query found in +// select_array.edgeql +func selectArray( + ctx context.Context, + client *edgedb.Client, +) ([]string, error) { + var result []string + + err := client.QuerySingle( + ctx, + selectArrayCmd, + &result, + ) + + return result, err +} + +// selectArrayJSON +// runs the query found in +// select_array.edgeql +// returning the results as json encoded bytes +func selectArrayJSON( + ctx context.Context, + client *edgedb.Client, +) ([]byte, error) { + var result []byte + + err := client.QuerySingleJSON( + ctx, + selectArrayCmd, + &result, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalar.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalar.edgeql new file mode 100644 index 0000000..ab290eb --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalar.edgeql @@ -0,0 +1 @@ +select 1; diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalar_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalar_edgeql.go.assert new file mode 100644 index 0000000..7769a02 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalar_edgeql.go.assert @@ -0,0 +1,53 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package scalar + +import ( + "context" + _ "embed" + + "github.com/edgedb/edgedb-go" +) + +//go:embed select_scalar.edgeql +var selectScalarCmd string + +// selectScalar +// runs the query found in +// select_scalar.edgeql +func selectScalar( + ctx context.Context, + client *edgedb.Client, +) (int64, error) { + var result int64 + + err := client.QuerySingle( + ctx, + selectScalarCmd, + &result, + ) + + return result, err +} + +// selectScalarJSON +// runs the query found in +// select_scalar.edgeql +// returning the results as json encoded bytes +func selectScalarJSON( + ctx context.Context, + client *edgedb.Client, +) ([]byte, error) { + var result []byte + + err := client.QuerySingleJSON( + ctx, + selectScalarCmd, + &result, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalars.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalars.edgeql new file mode 100644 index 0000000..43621c4 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalars.edgeql @@ -0,0 +1 @@ +select {1, 2, 3}; diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalars_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalars_edgeql.go.assert new file mode 100644 index 0000000..b2897dd --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/scalar/select_scalars_edgeql.go.assert @@ -0,0 +1,53 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package scalar + +import ( + "context" + _ "embed" + + "github.com/edgedb/edgedb-go" +) + +//go:embed select_scalars.edgeql +var selectScalarsCmd string + +// selectScalars +// runs the query found in +// select_scalars.edgeql +func selectScalars( + ctx context.Context, + client *edgedb.Client, +) ([]edgedb.Memory, error) { + var result []edgedb.Memory + + err := client.Query( + ctx, + selectScalarsCmd, + &result, + ) + + return result, err +} + +// selectScalarsJSON +// runs the query found in +// select_scalars.edgeql +// returning the results as json encoded bytes +func selectScalarsJSON( + ctx context.Context, + client *edgedb.Client, +) ([]byte, error) { + var result []byte + + err := client.QueryJSON( + ctx, + selectScalarsCmd, + &result, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/tuple/select_tuple.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/tuple/select_tuple.edgeql new file mode 100644 index 0000000..7bffdc1 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/tuple/select_tuple.edgeql @@ -0,0 +1 @@ +select ("abc", 123, ("xyz", 456)); diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/tuple/select_tuple_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project2/tuple/select_tuple_edgeql.go.assert new file mode 100644 index 0000000..7f495b9 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/tuple/select_tuple_edgeql.go.assert @@ -0,0 +1,71 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package tuple + +import ( + "context" + _ "embed" + + "github.com/edgedb/edgedb-go" +) + +//go:embed select_tuple.edgeql +var selectTupleCmd string + +// SelectTupleResult +// is part of the return type for +// selectTuple() +type SelectTupleResult struct { + Element0 edgedb.OptionalStr `edgedb:"0"` + Element1 edgedb.OptionalInt64 `edgedb:"1"` + Element2 SelectTupleResult2Item `edgedb:"2"` +} + +// SelectTupleResult2Item +// is part of the return type for +// selectTuple() +type SelectTupleResult2Item struct { + edgedb.Optional + Element0 edgedb.OptionalStr `edgedb:"0"` + Element1 edgedb.OptionalInt64 `edgedb:"1"` +} + +// selectTuple +// runs the query found in +// select_tuple.edgeql +func selectTuple( + ctx context.Context, + client *edgedb.Client, +) (SelectTupleResult, error) { + var result SelectTupleResult + + err := client.QuerySingle( + ctx, + selectTupleCmd, + &result, + ) + + return result, err +} + +// selectTupleJSON +// runs the query found in +// select_tuple.edgeql +// returning the results as json encoded bytes +func selectTupleJSON( + ctx context.Context, + client *edgedb.Client, +) ([]byte, error) { + var result []byte + + err := client.QuerySingleJSON( + ctx, + selectTupleCmd, + &result, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/select_args.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/select_args.edgeql new file mode 100644 index 0000000..0e6294c --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/select_args.edgeql @@ -0,0 +1,4 @@ +select { + Str := $str, + DateTime := $datetime, +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/select_args_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/select_args_edgeql.go.assert new file mode 100644 index 0000000..19a9293 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/select_args_edgeql.go.assert @@ -0,0 +1,74 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package when_no_go_files_in_dir_dir_name_becomes_package_name + +import ( + "context" + _ "embed" + "time" + + "github.com/edgedb/edgedb-go" +) + +//go:embed select_args.edgeql +var selectArgsCmd string + +// SelectArgsResult +// is part of the return type for +// selectArgs() +type SelectArgsResult struct { + Str string `edgedb:"Str"` + DateTime time.Time `edgedb:"DateTime"` +} + +// selectArgs +// runs the query found in +// select_args.edgeql +func selectArgs( + ctx context.Context, + client *edgedb.Client, + str string, + datetime time.Time, +) (SelectArgsResult, error) { + var result SelectArgsResult + + err := client.QuerySingle( + ctx, + selectArgsCmd, + &result, + map[string]interface{}{ + "str": str, + "datetime": datetime, + }, + ) + + return result, err +} + +// selectArgsJSON +// runs the query found in +// select_args.edgeql +// returning the results as json encoded bytes +func selectArgsJSON( + ctx context.Context, + client *edgedb.Client, + str string, + datetime time.Time, +) ([]byte, error) { + var result []byte + + err := client.QuerySingleJSON( + ctx, + selectArgsCmd, + &result, + map[string]interface{}{ + "str": str, + "datetime": datetime, + }, + ) + if err != nil { + return nil, err + } + + return result, nil +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/subpkg/ignore.go b/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/subpkg/ignore.go new file mode 100644 index 0000000..cd3a63e --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/subpkg/ignore.go @@ -0,0 +1 @@ +package zzz diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/subpkg/my_query.edgeql b/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/subpkg/my_query.edgeql new file mode 100644 index 0000000..add0a62 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/subpkg/my_query.edgeql @@ -0,0 +1,59 @@ +create scalar type MyScalar extending int64; +create scalar type MyEnum extending enum; + +select { + a := $a, + b := $b, + c := $c, + d := $d, + e := $e, + f := $f, + g := $g, + h := $h, + i := $i, + j := $j, + k := $k, + l := $l, + m := $m, + n := $n, + o := $o, + p := $p, + q := $q, + r := $r, + s := $s, + t := $t, + u := $u, + v := $v, + w := $w, + x := $x, + y := $y, + z := $z, + aa := $aa, + ab := $ab, + ac := $ac, + ad := $ad, + ae := $ae, + af := $af, + ag := $ag, + ah := $ah, + ai := $ai, + aj := $aj, + ak := >$ak, + al := >$al, + am := >$am, + an := >$an, + ao := >$ao, + ap := >$ap, + aq := >$aq, + ar := >$ar, + as := >$as, + at := >$at, + au := >$au, + av := >$av, + aw := >$aw, + ax := >$ax, + ay := 1, + az := {}, + ba := MyEnum.This, + bb := {}, +} diff --git a/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/subpkg/my_query_edgeql.go.assert b/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/subpkg/my_query_edgeql.go.assert new file mode 100644 index 0000000..62fd367 --- /dev/null +++ b/cmd/edgeql-go/testdata/pubtypes/test-project2/when_no_go_files_in_dir_dir_name_becomes_package_name/subpkg/my_query_edgeql.go.assert @@ -0,0 +1,319 @@ +// Code generated by github.com/edgedb/edgedb-go/cmd/edgeql-go DO NOT EDIT. + +package zzz + +import ( + "context" + _ "embed" + "math/big" + "time" + + "github.com/edgedb/edgedb-go" +) + +//go:embed my_query.edgeql +var myQueryCmd string + +// MyQueryResult +// is part of the return type for +// myQuery() +type MyQueryResult struct { + a edgedb.UUID `edgedb:"a"` + b edgedb.OptionalUUID `edgedb:"b"` + c string `edgedb:"c"` + d edgedb.OptionalStr `edgedb:"d"` + e []byte `edgedb:"e"` + f edgedb.OptionalBytes `edgedb:"f"` + g int16 `edgedb:"g"` + h edgedb.OptionalInt16 `edgedb:"h"` + i int32 `edgedb:"i"` + j edgedb.OptionalInt32 `edgedb:"j"` + k int64 `edgedb:"k"` + l edgedb.OptionalInt64 `edgedb:"l"` + m float32 `edgedb:"m"` + n edgedb.OptionalFloat32 `edgedb:"n"` + o float64 `edgedb:"o"` + p edgedb.OptionalFloat64 `edgedb:"p"` + q bool `edgedb:"q"` + r edgedb.OptionalBool `edgedb:"r"` + s time.Time `edgedb:"s"` + t edgedb.OptionalDateTime `edgedb:"t"` + u edgedb.LocalDateTime `edgedb:"u"` + v edgedb.OptionalLocalDateTime `edgedb:"v"` + w edgedb.LocalDate `edgedb:"w"` + x edgedb.OptionalLocalDate `edgedb:"x"` + y edgedb.LocalTime `edgedb:"y"` + z edgedb.OptionalLocalTime `edgedb:"z"` + aa edgedb.Duration `edgedb:"aa"` + ab edgedb.OptionalDuration `edgedb:"ab"` + ac *big.Int `edgedb:"ac"` + ad edgedb.OptionalBigInt `edgedb:"ad"` + ae edgedb.RelativeDuration `edgedb:"ae"` + af edgedb.OptionalRelativeDuration `edgedb:"af"` + ag edgedb.DateDuration `edgedb:"ag"` + ah edgedb.OptionalDateDuration `edgedb:"ah"` + ai edgedb.Memory `edgedb:"ai"` + aj edgedb.OptionalMemory `edgedb:"aj"` + ak edgedb.RangeInt32 `edgedb:"ak"` + al edgedb.OptionalRangeInt32 `edgedb:"al"` + am edgedb.RangeInt64 `edgedb:"am"` + an edgedb.OptionalRangeInt64 `edgedb:"an"` + ao edgedb.RangeFloat32 `edgedb:"ao"` + ap edgedb.OptionalRangeFloat32 `edgedb:"ap"` + aq edgedb.RangeFloat64 `edgedb:"aq"` + ar edgedb.OptionalRangeFloat64 `edgedb:"ar"` + as edgedb.RangeDateTime `edgedb:"as"` + at edgedb.OptionalRangeDateTime `edgedb:"at"` + au edgedb.RangeLocalDateTime `edgedb:"au"` + av edgedb.OptionalRangeLocalDateTime `edgedb:"av"` + aw edgedb.RangeLocalDate `edgedb:"aw"` + ax edgedb.OptionalRangeLocalDate `edgedb:"ax"` + ay int64 `edgedb:"ay"` + az edgedb.OptionalInt64 `edgedb:"az"` + ba string `edgedb:"ba"` + bb edgedb.OptionalStr `edgedb:"bb"` +} + +// myQuery +// runs the query found in +// my_query.edgeql +func myQuery( + ctx context.Context, + client *edgedb.Client, + a edgedb.UUID, + b edgedb.OptionalUUID, + c string, + d edgedb.OptionalStr, + e []byte, + f edgedb.OptionalBytes, + g int16, + h edgedb.OptionalInt16, + i int32, + j edgedb.OptionalInt32, + k int64, + l edgedb.OptionalInt64, + m float32, + n edgedb.OptionalFloat32, + o float64, + p edgedb.OptionalFloat64, + q bool, + r edgedb.OptionalBool, + s time.Time, + t edgedb.OptionalDateTime, + u edgedb.LocalDateTime, + v edgedb.OptionalLocalDateTime, + w edgedb.LocalDate, + x edgedb.OptionalLocalDate, + y edgedb.LocalTime, + z edgedb.OptionalLocalTime, + aa edgedb.Duration, + ab edgedb.OptionalDuration, + ac *big.Int, + ad edgedb.OptionalBigInt, + ae edgedb.RelativeDuration, + af edgedb.OptionalRelativeDuration, + ag edgedb.DateDuration, + ah edgedb.OptionalDateDuration, + ai edgedb.Memory, + aj edgedb.OptionalMemory, + ak edgedb.RangeInt32, + al edgedb.OptionalRangeInt32, + am edgedb.RangeInt64, + an edgedb.OptionalRangeInt64, + ao edgedb.RangeFloat32, + ap edgedb.OptionalRangeFloat32, + aq edgedb.RangeFloat64, + ar edgedb.OptionalRangeFloat64, + as edgedb.RangeDateTime, + at edgedb.OptionalRangeDateTime, + au edgedb.RangeLocalDateTime, + av edgedb.OptionalRangeLocalDateTime, + aw edgedb.RangeLocalDate, + ax edgedb.OptionalRangeLocalDate, +) (MyQueryResult, error) { + var result MyQueryResult + + err := client.QuerySingle( + ctx, + myQueryCmd, + &result, + map[string]interface{}{ + "a": a, + "b": b, + "c": c, + "d": d, + "e": e, + "f": f, + "g": g, + "h": h, + "i": i, + "j": j, + "k": k, + "l": l, + "m": m, + "n": n, + "o": o, + "p": p, + "q": q, + "r": r, + "s": s, + "t": t, + "u": u, + "v": v, + "w": w, + "x": x, + "y": y, + "z": z, + "aa": aa, + "ab": ab, + "ac": ac, + "ad": ad, + "ae": ae, + "af": af, + "ag": ag, + "ah": ah, + "ai": ai, + "aj": aj, + "ak": ak, + "al": al, + "am": am, + "an": an, + "ao": ao, + "ap": ap, + "aq": aq, + "ar": ar, + "as": as, + "at": at, + "au": au, + "av": av, + "aw": aw, + "ax": ax, + }, + ) + + return result, err +} + +// myQueryJSON +// runs the query found in +// my_query.edgeql +// returning the results as json encoded bytes +func myQueryJSON( + ctx context.Context, + client *edgedb.Client, + a edgedb.UUID, + b edgedb.OptionalUUID, + c string, + d edgedb.OptionalStr, + e []byte, + f edgedb.OptionalBytes, + g int16, + h edgedb.OptionalInt16, + i int32, + j edgedb.OptionalInt32, + k int64, + l edgedb.OptionalInt64, + m float32, + n edgedb.OptionalFloat32, + o float64, + p edgedb.OptionalFloat64, + q bool, + r edgedb.OptionalBool, + s time.Time, + t edgedb.OptionalDateTime, + u edgedb.LocalDateTime, + v edgedb.OptionalLocalDateTime, + w edgedb.LocalDate, + x edgedb.OptionalLocalDate, + y edgedb.LocalTime, + z edgedb.OptionalLocalTime, + aa edgedb.Duration, + ab edgedb.OptionalDuration, + ac *big.Int, + ad edgedb.OptionalBigInt, + ae edgedb.RelativeDuration, + af edgedb.OptionalRelativeDuration, + ag edgedb.DateDuration, + ah edgedb.OptionalDateDuration, + ai edgedb.Memory, + aj edgedb.OptionalMemory, + ak edgedb.RangeInt32, + al edgedb.OptionalRangeInt32, + am edgedb.RangeInt64, + an edgedb.OptionalRangeInt64, + ao edgedb.RangeFloat32, + ap edgedb.OptionalRangeFloat32, + aq edgedb.RangeFloat64, + ar edgedb.OptionalRangeFloat64, + as edgedb.RangeDateTime, + at edgedb.OptionalRangeDateTime, + au edgedb.RangeLocalDateTime, + av edgedb.OptionalRangeLocalDateTime, + aw edgedb.RangeLocalDate, + ax edgedb.OptionalRangeLocalDate, +) ([]byte, error) { + var result []byte + + err := client.QuerySingleJSON( + ctx, + myQueryCmd, + &result, + map[string]interface{}{ + "a": a, + "b": b, + "c": c, + "d": d, + "e": e, + "f": f, + "g": g, + "h": h, + "i": i, + "j": j, + "k": k, + "l": l, + "m": m, + "n": n, + "o": o, + "p": p, + "q": q, + "r": r, + "s": s, + "t": t, + "u": u, + "v": v, + "w": w, + "x": x, + "y": y, + "z": z, + "aa": aa, + "ab": ab, + "ac": ac, + "ad": ad, + "ae": ae, + "af": af, + "ag": ag, + "ah": ah, + "ai": ai, + "aj": aj, + "ak": ak, + "al": al, + "am": am, + "an": an, + "ao": ao, + "ap": ap, + "aq": aq, + "ar": ar, + "as": as, + "at": at, + "au": au, + "av": av, + "aw": aw, + "ax": ax, + }, + ) + if err != nil { + return nil, err + } + + return result, nil +}