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

Better way to query with many compound ids #569

Merged
merged 1 commit into from Mar 11, 2020
Merged

Conversation

pimeys
Copy link
Contributor

@pimeys pimeys commented Mar 9, 2020

Instead of doing

(id1 = 1 AND id2 = 2) OR (id1 = 3 AND id2 = 4)

we do

(id1, id2) IN ((1, 2), (3, 4))

and for SQLite

(id1, id2) IN (VALUES (1, 2), (3, 4))

@pimeys pimeys requested review from dpetrick and tomhoule March 9, 2020 18:20
@pimeys pimeys added this to the Preview 24 New milestone Mar 9, 2020
@pimeys pimeys self-assigned this Mar 9, 2020
Copy link
Contributor

@tomhoule tomhoule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with that code so I may have missed something, but it looks good to me

@@ -15,6 +15,7 @@ impl<'a> From<ParameterizedValue<'a>> for PrismaValue {
ParameterizedValue::Uuid(uuid) => PrismaValue::Uuid(uuid),
ParameterizedValue::DateTime(dt) => PrismaValue::DateTime(dt),
ParameterizedValue::Char(c) => PrismaValue::String(c.to_string()),
ParameterizedValue::Bytes(_) => todo!(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to get the types mapping PR merged today asap. But afaik this match branch is never reached.

Instead of doing

```sql
(id1 = 1 AND id2 = 2) OR (id1 = 3 AND id2 = 4)
```

we do

```sql
(id1, id2) IN ((1, 2), (3, 4))
```

and for SQLite

```sql
(id1, id2) IN (VALUES (1, 2), (3, 4))
```
@pimeys pimeys merged commit 7f34f22 into master Mar 11, 2020
@pimeys pimeys deleted the tuple-in-selection branch March 11, 2020 13:28
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.

None yet

3 participants