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

Update and clause of Peewee query #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

prashantsengar
Copy link

Without the paranthesis, peewee used to generate a query like this:

SELECT "t1"."id", "t1"."user_id", "t1"."message", "t1"."support_message_id", "t1"."private_message_id", "t1"."status", "t1"."resolved_at", "t1"."resolved_by_id", "t1"."created_at", "t1"."updated_at" FROM "support_tickets" AS "t1" WHERE (({USER_ID} AND "t1"."status") = 0)

It would always return all the user IDs created by all users.

Updating the peewee query generates the following SQL query:

SELECT "t1"."id", "t1"."user_id", "t1"."message", "t1"."support_message_id", "t1"."private_message_id", "t1"."status", "t1"."resolved_at", "t1"."resolved_by_id", "t1"."created_at", "t1"."updated_at" FROM "support_tickets" AS "t1" WHERE (("t1"."user_id" = {USER_ID}) AND ("t1"."status" = 0))

prashantsengar and others added 2 commits August 16, 2024 13:44
Without the paranthesis, peewee used to generate a query like this:

```
SELECT "t1"."id", "t1"."user_id", "t1"."message", "t1"."support_message_id", "t1"."private_message_id", "t1"."status", "t1"."resolved_at", "t1"."resolved_by_id", "t1"."created_at", "t1"."updated_at" FROM "support_tickets" AS "t1" WHERE (({USER_ID} AND "t1"."status") = 0)
```

It would always return all the user IDs created by all users.

Updating the peewee query generates the following SQL query:

```
SELECT "t1"."id", "t1"."user_id", "t1"."message", "t1"."support_message_id", "t1"."private_message_id", "t1"."status", "t1"."resolved_at", "t1"."resolved_by_id", "t1"."created_at", "t1"."updated_at" FROM "support_tickets" AS "t1" WHERE (("t1"."user_id" = {USER_ID}) AND ("t1"."status" = 0))
```
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

Successfully merging this pull request may close these issues.

1 participant