Skip to content

Mysql: add Encode impl for &[T] #3639

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

Closed
dyc3 opened this issue Dec 15, 2024 · 1 comment
Closed

Mysql: add Encode impl for &[T] #3639

dyc3 opened this issue Dec 15, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@dyc3
Copy link

dyc3 commented Dec 15, 2024

Is your feature request related to a problem? Please describe.
I was looking for an easy way to do bulk SELECTs by passing in an array of values (in my case, integer primary keys). I came up with this query:

SELECT id, username, first_name, last_name, profile_photo_url
        FROM UserProfiles
        WHERE id IN (?);

I went on to find that the Encode impl for &[T] was only present for Postgres

Describe the solution you'd like

Basically, I want impl<'q, T> Encode<'q, Mysql> for &[T] where T: Encode<'q, Mysql>

Describe alternatives you've considered
The alternative is to just make single queries in a loop. Another alternative is to build a dynamic query where I append OR id == ? to the where clause for every id I want to grab.

Additional context
None

@dyc3 dyc3 added the enhancement New feature or request label Dec 15, 2024
@abonander
Copy link
Collaborator

Those impls exist for Postgres because it supports arrays as a native datatype. MySQL does not.

To support binding an array in that case, we'd have to implement some sort of comma-expansion which is a planned feature covered by #875.

@abonander abonander closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants