Skip to content
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

Generated test code uses queries.Assign instead of a simple = (assign operator) #1224

Open
netayg opened this issue Nov 30, 2022 · 0 comments
Labels

Comments

@netayg
Copy link

netayg commented Nov 30, 2022

If you're having a generation problem, please answer these questions before submitting your issue. Thanks!

What version of SQLBoiler are you using (sqlboiler --version)?

SQLBoiler v4.11.0

What is your database and version (e.g. Postgresql 10)

PostgreSQL 13.6 (Debian 13.6-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit

If this happened at generation time, what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)

If this happened at runtime what code produced the issue? (if not applicable, leave blank)

Generated tests for one of our models.
The model has an ID of enum (string).
This enum is also the ID of another model.

For example:

model Balance:
ID (uuid)
Value (int)
Type (BalanceTypes)

model BalanceTypes:
ID (enum.Code)
Description (string)

enum Code:
"a",
"b",
"c"

The code generates a test that created both local and foreign values, inserts the foreign to the DB and tries to use queries.Assign to set the value of local.Type to be the same as the foreign's.
The function Assign doesn't support primitive types (such as string and string, caused by both being enums)
So it panics.

What is the output of the command above with the -d flag added to it? (Provided you are comfortable sharing this, it contains a blueprint of your schema)

See example above

Please provide a relevant database schema, so we can replicate your issue (Provided you are comfortable sharing this)

See example above

Further information. What did you do, what did you expect?

I expect the generator for the code to detect enums and treat them as strings. That way it will not use queries.Assign and will use just a simple = instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants