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

Numeric Field as Column with precision -> "pq: numeric field overflow" #2068

Open
1 task done
nabl13 opened this issue Jan 22, 2025 · 0 comments
Open
1 task done

Numeric Field as Column with precision -> "pq: numeric field overflow" #2068

nabl13 opened this issue Jan 22, 2025 · 0 comments
Assignees

Comments

@nabl13
Copy link

nabl13 commented Jan 22, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Version of Corteza

2023.9.8

Current Behavior

I have a Numeric field with configured precision of 2.
When i configure this Field to be saved as a Column instead of JSON in PostgreSQL, the column will be created as follows:

CREATE TABLE "compose_record_modulename" (
	...
	"sekunden" NUMERIC(2,0) NULL DEFAULT NULL,
        ...

This is wrong, when i try to insert any number bigger then 2 digts (f.e. 100) it will raise an error: "pq: numeric field overflow"

According to the psql Doc: https://www.postgresql.org/docs/current/datatype-numeric.html

the first value defines the total length of the value and the second one the decimal places.

so NUMERIC(2,0) accepts 0-99
when i change it to NUMERIC() it just works with whatever is configured in Corteza.

Expected Behavior

Numeric fields should be defined correctly in postgreSQL if saved as column.
I think it would be just fine to leave the check logic to corteza and store the column as simple NUMERIC()

Steps To Reproduce

  1. create module
  2. create Numeric field with defined precision
  3. change the storage of the field to "Column" instead of "JSON"
  4. try to save any value bigger then the defined precision (precision:2 -> try save 100)

Environment and versions

Anything else?

No response

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

No branches or pull requests

2 participants