-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Issue with exponents in numbers being dropped when using updateRaw
with Postgres
#273
Comments
Did you try |
I believe |
Shit right. Sorry. Yeah I can't reproduce this using H2 and my unit tests. It's the raw methods that need the strings. |
Yea, it was really strange, the same code running in production was not producing the issue. Issuing queries in pgAdmin manually using the same syntax ( |
I bet it is the postgres driver that is doing the conversion of 7.527E7 to the double. I bet it is doing a isDigit() or == '.' and just stopping at the In terms of the pgAdmin, did you try '7.527E7' i.e. in quotes? |
I think you should be able to use the
Does that work? See: https://ormlite.com/docs/update-builder You can also set the compiled expression and then update it a bunch:
|
Here is a quick test with API tracing on in the JDBC driver (PGJDBC-NG): I changed the above code to do:
Querying for that order in pgAdmin after the update shows me the column has the value I can investigate this more this evening and I'll let you know if I find anything out. The reason I'm not using the update builder here is I'm inserting into a temporary table with a different name than my row class ( |
Good test. Sounds like you've got a handle on it. Doesn't seem to the ORMLite's fault which is good. ;-) I'd create a Have you tried some of the postgres |
Yep, agreed this seems to be out of ORMLite's realm. Feel free to close this out :) Ah, of course - yes I'll extend the entity and just do that. That will clean things up nicely. Haven't tried casting - I am curious about the root cause. Kind of a scary silent parsing failure somewhere, heh. Cheers, and thanks for the help. |
Happy to help Casey. Best of luck. Let me know if there is anything ORMLite could have done better. I think that I'm going to add a
|
That would be perfect for cases like this! |
hope it helps you. |
I used using an updateRaw statement of the form:
For some values of price, specifically ones with exponents, such as
7.527E7
. The value would end up in the database as7.527
.The database in question is my local testing database:
PostgreSQL 13.2, compiled by Visual C++ build 1914, 64-bit
. However, I didn't see the issue on my production DBPostgreSQL 13.4 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 11.2.1 20211203 (Red Hat 11.2.1-7), 64-bit
. Both running the same version of ormlite.If it's relevant,
market_orders_temp
is a temp table created within the same transaction (ie, not the same table as the dao thatupdateRaw
is called on).I was able to work around the issue by using a CompiledStatement directly:
I'm thinking this is some oddity with converting strings to numbers with specific database versions, or possibly differing JDKs?
The text was updated successfully, but these errors were encountered: