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

Sqlite view model has wrong type and can't be replaced #1369

Closed
ShinyZero0 opened this issue Mar 30, 2024 · 5 comments
Closed

Sqlite view model has wrong type and can't be replaced #1369

ShinyZero0 opened this issue Mar 30, 2024 · 5 comments
Labels

Comments

@ShinyZero0
Copy link

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)?

4.16.1

What is your database and version (eg. Postgresql 10)

3.44.2

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

sqlboiler sqlite3

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

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)

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

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

It generates the entity for client_balance with balance as nullable string, which is a float actually. E.g. if i do a query with sqlite3 -json it is float

There is the whole repo

@ShinyZero0
Copy link
Author

UPD: it's the same for client_statuses view too. Also, the values are valid, but i have to parse them with strconv

@stephenafamo
Copy link
Collaborator

I will label this as a bug, but I need more information

The title says it can't be replaced, can you share how you are configuring the type replacement?

@ShinyZero0
Copy link
Author

like that

AFAIR i also tried matching the capitalized name and it didn't work too

@ShinyZero0
Copy link
Author

@stephenafamo
Any updates on this? 4.16.2 still has the problem.
I tried replacing like that:

[[types]]
	[types.match]
	type = "null.String"

	[types.replace]
	type = "float32"

the matcher is literally copied from README so it must work, but it doesn't. I still have the null.String balance field.

Are there ways to add more clues to my db schema so that sqlboiler could infer the types correctly?

@ShinyZero0
Copy link
Author

I just tried the following and it worked. I thought less matchers must match more as it uses logical AND. That "boolean values must always match" in doc sounds ambiguous imo.

[[types]]

	[types.match]
	name = "balance"
	nullable = true

	[types.replace]
	type = "float32"

So, i at least know how to fix it myself now. If it's not possible to do more accurate type detection on views, the issue can be closed

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