Sqlx: question: how to preform query with variable length of param?

Created on 30 Jan 2020  路  5Comments  路  Source: launchbadge/sqlx

Assumes that I want to filter rows by checking if their ids are in the specific range.

In pure SQL, I can do something like

select * from foo where id in ('0', '1', '2');

But it seems like sqlx doesn't support that syntax:

sqlx::query!(
    "select * from foo where id in $1",
    vec!["0", "1", "2"] // error
);

So is there any workaround to perform such query, or this feature is not yet implemented?

postgres question

Most helpful comment

master now has full support for arrays and vectors in parameter and result position

All 5 comments

So is there any workaround to perform such query, or this feature is not yet implemented?

The feature isn't implemented yet. We don't support arrays quite yet.

Any idea when this might change? Currently evaluating sqlx for a project and this is kinda a deal breaker.

Principal implementation for arrays is in #110, I'm looking over it now. It will probably be rebased and merged into develop for inclusion in #111. When that will be merged depends on if @mehcode gets a chance to finish up the refactors for MySQL this weekend since I'll be out of town (although I'm taking a laptop so I could potentially work on it).

master now has full support for arrays and vectors in parameter and result position

Hi, is there a plan to support this feature in mysql ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ecton picture ecton  路  5Comments

4parsleythelion picture 4parsleythelion  路  9Comments

abonander picture abonander  路  3Comments

mehcode picture mehcode  路  8Comments

c410-f3r picture c410-f3r  路  8Comments