-
Notifications
You must be signed in to change notification settings - Fork 41
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
Kart truncates trailing zeroes in values of type numeric
#863
Comments
kart import
mangles PK fields with type numeric
kart import
truncates trailing zeroes in values of type numeric
💥 found it kart/kart/sqlalchemy/adapter/postgis.py Line 425 in 99e48a2
|
Did a quick test - this affects reading of PG numeric types in general, not just at import time (ie, also at diff / commit time). |
Actually I suspect we shouldn't be removing trailing zeroes at all - the idea of numeric is that it's fixed-precision, but removing trailing zeroes even from the right of the decimal point lowers the precision. Any idea why that's there? |
Probably something do with fixing this roundtrip so that nothing changes: |
Does it? From the PG docs:
The latter is PG-specific obviously. From the above, for a column defined as |
Rob is right - removing trailing zeroes after a decimal point when we store it in the Kart model - which is when this code is fired - won't do anything to what we put in the PG database - it doesn't affect the value of the numeric, and it can't affect the precision of the numeric, which is stored separately. |
is what I was referring to. The precision in the value is supposed to be retained, so |
I think it should - that's a material change to an unconstrained numeric. For constrained numerics it matters less but the canonical form ideally would be the one with the intended number of zeroes present |
https://github.com/koordinates/kart/blob/master/docs/pages/development/table_v3.rst#data-types doesn't make it clear whether Kart supports unconstrained numerics - maybe we should clarify that and ensure we can roundtrip various types of values sanely between PG and GPKG etc |
kart import
truncates trailing zeroes in values of type numeric
numeric
Hmm you are right - probably we can add a separate "1.0" vs "1" to the Kart model, since:
This is a minor issue compared to the main truncating zeroes issue however |
Describe the bug
Importing from a database table where a field has
NUMERIC
type causes any trailing zeroes in the PK to be stripped.To Reproduce
Expected behaviour
the values should be unchanged
Output
Values
13390
,200000
, and0
all had their trailing zeroes stripped.This isn't just a
diff
issue - the PKs were mangled during the import.As far as I got with debugging was that it happens inside SQLalchemy (here)
**Version Info **
The text was updated successfully, but these errors were encountered: