You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a select query with a parameter, an integer value is correctly identified as an INT4 (type = 23):
awaitsql`CREATE TABLE foo (id int)`;console.log(awaitsql`SELECT * from foo WHERE id = ${1}`.describe(),);// {// string: 'SELECT * from foo WHERE id = $1',// types: [ 23 ],// name: '9njwfoixz23',// columns: [// {// name: 'id',// parser: [Function: parse],// table: 462973,// number: 1,// type: 23// }// ]// }
However, for a query over a VALUES table, the same parameterized value is identified as TEXT (type = 25):
console.log(awaitsql`WITH bar (id) AS (VALUES (${1})) SELECT * FROM bar`.describe(),);// {// string: 'WITH bar (id) AS (VALUES ($1)) SELECT * FROM bar',// types: [ 25 ],// name: 'owdbjhlx58l2',// columns: [ { name: 'id', parser: undefined, table: 0, number: 0, type: 25 } ]// }
And the result is similarly incorrect ({ id: '1' }).
Is this expected, and if so, is there a way to infer the value type from the JavaScript type?
The text was updated successfully, but these errors were encountered:
darkgnotic
changed the title
Parameter type inference not working for temporary tables?
Parameter type inference not working for VALUES tables?
Apr 6, 2024
For a select query with a parameter, an integer value is correctly identified as an
INT4
(type = 23):However, for a query over a VALUES table, the same parameterized value is identified as
TEXT
(type = 25):And the result is similarly incorrect (
{ id: '1' }
).Is this expected, and if so, is there a way to infer the value type from the JavaScript type?
The text was updated successfully, but these errors were encountered: