Open cloleb opened 8 months ago
drizzle-orm
0.28.6
drizzle-kit
0.19.13
When including a relationship in a query using 'with', if the relationship (children table) contains a numeric field, the numeric field is returned as a float instead of a string, removing all precision on the numeric.
Example
the following query:
const query = await db.query.tableA.findOne({ with: { tableB: true } })
will return something like this:
{id:1, tableB: {id: 1, amount: 2.3}}
instead of this:
{id:1, tableB: {id: 1, amount: '2.30'}}
Important note
This problem only occurs when selecting/including tableB in a query using 'with'. Querying tableB directly like this:
await db.query.tableB.findOne()
will return the following (which is correct):
{id: 1, amount: '2.30'}
Numerics should be returned as strings when using 'with'
Postgres (node-postgres)
https://github.com/drizzle-team/drizzle-orm/issues/1042#issuecomment-1722551657
Same here, breaking many things. Any news?
What version of
drizzle-orm
are you using?0.28.6
What version of
drizzle-kit
are you using?0.19.13
Describe the Bug
When including a relationship in a query using 'with', if the relationship (children table) contains a numeric field, the numeric field is returned as a float instead of a string, removing all precision on the numeric.
Example
the following query:
const query = await db.query.tableA.findOne({ with: { tableB: true } })
will return something like this:
{id:1, tableB: {id: 1, amount: 2.3}}
instead of this:
{id:1, tableB: {id: 1, amount: '2.30'}}
Important note
This problem only occurs when selecting/including tableB in a query using 'with'. Querying tableB directly like this:
await db.query.tableB.findOne()
will return the following (which is correct):
{id: 1, amount: '2.30'}
Expected behavior
Numerics should be returned as strings when using 'with'
Environment & setup
Postgres (node-postgres)