Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error on sql tagged template string #99

Open
Eprince-hub opened this issue Nov 10, 2022 · 0 comments
Open

Unexpected error on sql tagged template string #99

Eprince-hub opened this issue Nov 10, 2022 · 0 comments

Comments

@Eprince-hub
Copy link

Describe the bug
SafeQL throws multiple errors when using the sql tagged template string on Postgres, which leads to the errors below
Invalid Query: the type "string | PendingQuery<Row[]>" is not supported and Invalid Query: Error: syntax error at or near "DEFAULT" The query below will throw the above errors

export async function query(a: number, b: string, c: string) {
  return await sql`
    UPDATE
      try_safe_ql
    SET
      b = ${b},
      c = ${c || sql`DEFAULT`}
    WHERE
      a = ${a}
  `;
}

To Reproduce
Steps to reproduce the behavior:

  1. Setup SafeQL
  2. Use this code in .ts file
export async function query(a: number, b: string, c: string) {
  return await sql`
    UPDATE
      try_safe_ql
    SET
      b = ${b},
      c = ${c || sql`DEFAULT`}
    WHERE
      a = ${a}
  `;
}

Expected behavior
There shouldn't be an error when using sql tagged template string
**
Screenshot 2022-11-10 at 13 31 01
Screenshot 2022-11-10 at 12 41 14
Screenshots**

Desktop (please complete the following information):

  • OS: MAC OS
  • PostgreSQL version 14
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant