Skip to content

For postgres, applying type information to a bind variable does not work. #18

@besk-cerity

Description

@besk-cerity

I encountered this issue when using an ANY function as a replacement for an IN clause. I created a mocha test to illustrate the problem:

it('pg bind array using ANY clause with type cast', () => {
  const query = 'SELECT id::int FROM user WHERE id=any(:idList::int[]) and born > :year;'
  const data = {idList: [1, 2, 3], year: 2000}
  const expected = {
    text: 'SELECT id::int FROM user WHERE id=any($1::int[]) and born > $2;',
    values: [[1, 2, 3], 2000]
  };
  assert.deepEqual(yesql.pg(query)(data), expected)
})

This used to work when we were using v3.2.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions