Skip to content

A question about the SqliteException: too many SQL variables #2763

Answered by simolus3
HasanAlqaisi asked this question in Q&A
Discussion options

You must be logged in to vote

Is there a way to make a query in drift API don't rely on variables

You can use isNotInExp([for (final id in serverIds) Constant(id)]).

But I don't recommend running these huge statements - since you're already using a batch, you could delete a single row at a time:

await batch((batch) {
  for (final id in serverIds) {
    batch.deleteWhere(visitsTable, (tbl) => tbl.serverId.isNotNull() & tbl.serverId.equals(id));
  }
});

Since these all generate the same SQL (with different values being bound to the variable), that might be better for the database.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@HasanAlqaisi
Comment options

@simolus3
Comment options

@HasanAlqaisi
Comment options

@simolus3
Comment options

Answer selected by HasanAlqaisi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants