Problem with big decimal field on table creation
See original GitHub issueQueryFailedError: 🔨 Not supported 🔨 : The query you ran generated an AST which parts have not been read by the query planner. This means that those parts could be ignored:
⇨ .columns[6].dataType.config ([200,2])
👉 pg-mem is work-in-progress, and it would seem that you've hit one of its limits.
*️⃣ Failed SQL statement:
CREATE TABLE "public"."activity" (
... [ redacted ] ...
"amount" numeric(200,2),
... [ redacted ] ...
);
at new QueryFailedError (.../src/error/QueryFailedError.ts:9:9)
at .../src/driver/postgres/PostgresQueryRunner.ts:188:30
at Timeout._onTimeout (.../node_modules/pg-mem/src/adapters.ts:123:42)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Four common pitfalls of the BigDecimal class and how to ...
Here, the x value has lost four decimal digits because a double has a precision of only 15–17 digits (a float has a...
Read more >When a BigDecimal value is inserted into a NUMERIC column ...
When a BigDecimal value is inserted into a NUMERIC column using the Simba JDBC Driver for BigQuery, why is the numeric precision lost?...
Read more >Math operations with decimal data type returning incorrect ...
Math operations with decimal data type returning incorrect values when using PreparedStatement and BigDecimal objects #1489. Open.
Read more >Big Decimal (BigDecimal) Support for Real Numbers - IBM
The storage. bigDecimalRoundingMode property sets the rounding mode when Big Decimal is used. The default is HALF_UP, meaning that the rounding mode is...
Read more >Decimal value is rounded up/down to integer value - Office
To work around this problem, manually set the Field Size property of the column to Double or to Decimal. Click the DataSheet tab....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi, It would be easy to implement it naïvely, meaning that table creation would work, and usual operations as well.
BUT, doing that would not implement the actual behaviour of
numeric, which is quite complex.This would mean that you could get inconsistent results (numbers would not be truncated to the defined numeric precision, “Infinity” and “NaN” would not exist, …) 👉 These numbers would not behave exactly as actual postgres
numericvalues, and your tests might not behave as expected 🤷♂️So, just a quick poll (anyone can answer): Vote 👍 if it would be of any use to implement that naïve version Vote 👎 if it’s useless, and you want to wait until I have enough time to implement a real
numerictypeNow that I think about it, this workaround should work as well:
This should replace all
numeric(x,y)instances in the executed queries withfloat.And at least, if you copy-paste that, you know that you’re doing something wrong for your numeric types 😄
disclaimer: not tested 😃
disclaimer 2: dont try to insert strings that contain
numeric(x,y)😅Tell me if it works… (it is in fact equivalent to the naive implementation) If it does, i’ll wait