Numeric // Decimal Postgres types are inferred as strings and expect string as an input as well

No description
5 Replies
bloberenober
bloberenober15mo ago
That is intentional - numeric and decimal are used to store values with huge precision/number of digits, so it only makes sense to store them as strings. For regular numbers, you can use integer, bigint, doublePrecision, real. Otherwise, how would you represent a number with 65 digits after the decimal point in JS?
rushil1o1
rushil1o115mo ago
Ah I see, so they're just converted to string to avoid losing precision in typescript ? if I pass a string representation to LTE and GTE queries, would is still correctly filter by Less Than and Greater Than?
bloberenober
bloberenober15mo ago
I guess it depends on Postgres - if it supports LTE/GTE on numerics, I don't see why it shouldn't work.
rushil1o1
rushil1o115mo ago
Sounds good - for our use case we just decided to use double precision since it was within the precision limits we wanted and its better to not deal with string numbers in typescript
bloberenober
bloberenober15mo ago
That's how we planned it to be used - if your precision limits can be expressed in JS, use double precision, otherwise use numeric with strings
Want results from more Discord servers?
Add your server
More Posts
Cannot read properties of undefined (reading '0')What is the expected behavior when using `get()` when there would be no matching results for a giveIs it recommended to create a SQL transaction every time we try to create a foreign relationship?prisma used to wrap every foreign upsert (2 entities) within a transaction to guarantee that both roDoesn't drizzle-kit generate:pg work yet when schema imports from esm package?``` > drizzle-kit generate:pg --out src/db/migrations --schema src/db/schemas drizzle-kit: v0.17.0 Is there `.returning()` in insert statement in MySQL like SQLite?There is `.returning()` insert statement in SQLite but MySQL not. how do I `.returning()` in insertCan you please release this commit?https://github.com/drizzle-team/drizzle-orm/commit/63134f21ab5ccbdb651a63c1ac0f6d5e8bbe2002 I'm getGetting results in document form rather than recordHi, new to drizzle but liking it so far. Is there away to get the results in more of a 'document' strequire() of ES Module is not supported planetscale serverless + sveltekitHi, I am getting this error when I user planetscale serverless with drizzle orm ``` require() of ESMySQL Standalone queryBuilder?https://discord.com/channels/1043890932593987624/1052239146699210863/1085708651374837810 Where shouWhat is the type for an .orderBy() parameterInside of a function, i have a query more complicated than this, but something like: ```ts db.selecMySqlInsertValue<> vs typeof Table type mismatchI've got this line of code: ```ts await db.insert(table).values(props); ``` Where `props` is showi