-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schema.Enums contains one value for each value instead of each type #115
Comments
It actually seems to work fine if you just omit the join on SELECT n.nspname, t.typname as type
FROM pg_type t
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
WHERE (t.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid))
AND NOT EXISTS(SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem AND el.typarray = t.oid)
AND n.nspname = IN (%s) |
Running into this issue right now, would love to see the fix merged in! |
Sorry for the delay, I'll take a look tonight and try to get that PR merged in. |
Sorry for the PR noise. I had to do some branch cleanups to use this locally. |
Hate to be that guy, but... bump? |
Gah, sorry. I appreciate the bump. I'll try to look at this tonight. |
Hi @natefinch, is there something else you'd like to see for the PR? I can add a test case to |
A test would be great, thank you! Sorry for the delay in responding! |
After looking at this again, I realize a test case in I've been using this in my fork for a long time now without issue. If you're using enums for anything other than producing one file per, such as with This issue will manifest in the grpc template I'm about to push. The example SQL (which I copied from Let me know what else you need to get this merged. |
As the title says, when ranging
.Schema.Enums
in a[SchemaPaths]
template, each enum is repeated once for each associated value, when it should just range once for each enum type. You can see this also in the verbose output when running gnorm:This may be PostgreSQL only, as I think the culprit is the following query:
gnorm/database/drivers/postgres/parse.go
Lines 599 to 605 in d696814
I would have submitted a PR, but I'm not great at SQL and can't figure out how to adjust the query. The results could obviously be de-duplicated in code, but that seems like a second choice solution.
My hunch as to why this went unnoticed is that when the values generated are passed to
[EnumPaths]
templates, generally one file is created per enum and you wouldn't know if they were written multiple times.The text was updated successfully, but these errors were encountered: