Closed bera-josh-jewell closed 2 years ago
I just verified that installing via go install and running the author example works on main:
go install github.com/jschaf/pggen/cmd/pggen@latest
cd pggen/example
~/go/bin/pggen gen go --schema-glob author/schema.sql --query-glob author/query.sql
Does running the example from the repo work? My guess is that either schema file or query file has changed. The author example doesn't use json so that's odd. Can you verify the content hasn't changed?
thanks so much for getting back to me. I just pulled the repo and then tried again. I am getting the same error. It is really odd it's complaining about json. Is that how it serializes the data?
Here is my error
Could this have anything to do with me running on windows?
I’d suspect the database setup before blaming Windows. Pggen mostly just connects to Postgres
You’ll need Docker to run pggen without a Postgres connection. If the Docker approach works it’s probably the DB setup.
Just wanted to report back that using the docker image for postgres seemed to do the trick. Any guesses on what could be causing an issue with our existing database server?
Any guesses on what could be causing an issue with our existing database server?
What's the output if you run the pggen queries manually, replacing the pggen.arg
with a value? It might also help to add some data to the table to see the shape of data.
Going to close as issue was resolved.
I am just trying to get through a basic tutorial. I installed through go install:
go install github.com/jschaf/pggen/cmd/pggen@latest
Then tried to run the following command against my postgres database:
pggen gen go \ --schema-glob author/schema.sql \ --query-glob author/query.sql
it creates the author schema in the database correctly, but I get the following error while trying to generate code for query.sql:
ERROR: parse template query file "C:\\code\\api-brand-allocation\\author\\query.sql": infer typed named query FindAuthorByID: infer output types for query: infer output type nullability: explain prepared query: can't scan into dest[0]: json: cannot unmarshal number into Go value of type map[string]interface {}
I pulled my query.sql and schema.sql from the following location:https://github.com/jschaf/pggen/tree/main/example/author
Can't figure out what I missed, hopefully something simple. Thanks!