Skip to content

SELECT IN Queries Failing #27

Description

@drveresh

The following is failing to get records despite the same query works in the Console.

Endpoint:
../productGetByCountries?cx=JP,DE

EdgeFunction Code:

    const cx = decodeURIComponent(request.params.cx);
    const arrayWithSingleQuotes = cx.split(',').map(item => `'${item}'`);
    const outputString = arrayWithSingleQuotes.join(',');

    console.log("query: " + `SELECT * FROM products WHERE country IN (${outputString}) LIMIT 5`);
    console.log("outputString: " + `${outputString}`);
    result = await connection.sql`SELECT * FROM products WHERE country IN (${outputString}) LIMIT 5`;

Log Console:

query: SELECT * FROM products WHERE country IN ('DE','JP') LIMIT 5
outputString: 'DE','JP'

Response:
"result": []

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions