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

Negative Take Value Generates Invalid SQL #1396

Closed
BlurrechDev opened this issue Jan 2, 2023 · 1 comment
Closed

Negative Take Value Generates Invalid SQL #1396

BlurrechDev opened this issue Jan 2, 2023 · 1 comment
Labels
bug Invalid compiler output or panic compiler

Comments

@BlurrechDev
Copy link
Contributor

BlurrechDev commented Jan 2, 2023

The following is the result of some testing via https://prql-lang.org/playground/

Minimal example 1:

prql sqldialect:mysql
from employees | take (-1)

Generates the following invalid SQL:

SELECT
  *
FROM
  employees
LIMIT
  -1 L

Minimal example 2:
Any range starting with a number less than 1 has a similar issue.

prql sqldialect:mysql
from employees | take (0..1)

Generates the following SQL with a disallowed negative offset:

SELECT
  *
FROM
  employees
LIMIT
  2 OFFSET -1
 

As an aside, I'm big fan of this project and I only wish it had existed years ago. 👍 🥇

@aljazerzen aljazerzen added bug Invalid compiler output or panic compiler labels Jan 2, 2023
@aljazerzen
Copy link
Member

Closed by #1397 as:

Error:
    ╭─[:58:18]
    │
 58 │ from employees | take (0..1)
    ·                  ─────┬─────
    ·                       ╰─────── take expected a positive int range, but found 0..1
────╯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Invalid compiler output or panic compiler
Projects
None yet
Development

No branches or pull requests

2 participants