我正在尝试从表中选择一个项目,其中给定数字适合其成本范围。
如果我手动将$/cost/
设置为3.136
,这似乎可以工作,但是一旦我尝试使用命名参数,它就会失败。我在完整查询中使用了其他变量,它们都工作正常,这使我相信我做错了一些事,因为它与pg-promise和numrange
db.one('SELECT id FROM cost_table WHERE range @> $/cost/', { cost })
我得到了错误
Server running on port 5000
[0] { error: malformed range literal: "3.316"
[0] at Connection.parseE (\node_modules\pg\lib\connection.js:602:11)
...
So on so forth
...
name: 'error',
[0] length: 137,
[0] severity: 'ERROR',
[0] code: '22P02',
[0] detail: 'Missing left parenthesis or bracket.',
[0] hint: undefined,
[0] position: '1896',
[0] internalPosition: undefined,
[0] internalQuery: undefined,
[0] where: undefined,
[0] schema: undefined,
[0] table: undefined,
[0] column: undefined,
[0] dataType: undefined,
[0] constraint: undefined,
[0] file: 'rangetypes.c',
[0] line: '2092',