Skip to content

Query variable by using .unsafe with .values() and then .columns will result in NULL instead of columns #350

@half-metal

Description

@half-metal

Initially I just wanted to use a variable string as the query and found I could do this by using .unsafe(query). However, when I chain .values() with this, and then attempt to use .columns with the result, it now ends up as NULL instead of the columns. Below is the example code:

result = await sql.unsafe(query).values() console.log('result in call is:', result.columns)
And console will now be
result in call is: null
Which normally gives the column names.

If values() doesn't work with .unsafe, is there an alternative to using a javascript variable as the query. e.g.
query = "Select * from schema.table" then just use sql${query}.values() ?

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