Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Update and clause of Peewee query#1

Open
prashantsengar wants to merge 2 commits into
mikurei:mainfrom
prashantsengar:main
Open

Update and clause of Peewee query#1
prashantsengar wants to merge 2 commits into
mikurei:mainfrom
prashantsengar:main

Conversation

@prashantsengar
Copy link
Copy Markdown

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant