Repository navigation
Description
👟 Reproduction steps
- Table with columns
n(integer),ds(varchar),ix(varchar),grp(varchar). Two rows in groupg: row A{ix: "keep", n: 1, ds: "orig"}, row B{ix: "other", n: 9, ds: "orig"}. - Create a transaction and stage three operations:
updateA on an unrelated field (so A enters the transaction state),bulkUpdatewithdata: {ds: "BULK", n: increment 100}and queries[equal grp=g, notStartsWith ix="ke"]— in the database this matches only B, not A (ix="keep"starts withke),upsertA (writes A back from the state).
- Commit and read A.
👍 Expected behavior
A keeps ds="orig", n=1: the bulkUpdate filter does not match A, so A must not be changed. (With a supported filter like equal ix="other" this is exactly what happens — control case.)
👎 Actual Behavior
A is changed to ds="BULK", n=101, although the database query excludes it. Any query operator that TransactionState::documentMatchesFilters() does not implement makes every row already in the transaction state match, so a bulkUpdate/bulkDelete hits rows it should skip.
Affected operators (each 2 runs, identical): notStartsWith, notEndsWith, notContains, notBetween, or, and equal on a null column (equal u="" matched A whose u is null). Supported operators work correctly (equal, notEqual, startsWith, endsWith, greaterThan, lessThan, between, isNull, isNotNull). notSearch happens to fail the commit with 400 (fulltext required), so it does no damage.
A row is only affected if the transaction already touched it before the bulk operation (created/updated/upserted it, or an earlier bulk matched it); rows not yet in the state are matched correctly against the database (control H701). bulkDelete with an unsupported filter instead triggers a 409 conflict (H702).
Cause: TransactionState::documentMatchesFilters() (TransactionState.php L632–L740) has a switch over the query method with cases only for equal, notEqual, contains, startsWith, endsWith, greaterThan, greaterThanEqual, lessThan, lessThanEqual, isNull, isNotNull, between. For any other method there is no case and no default, so the loop falls through and the function returns true at the end (L739). applyBulkUpdateToState() (L248) then applies the bulk data to those state documents, and handleBulkUpdateOperation() re-writes them (Transactions/Update.php L888–L944). main has the same code. The equal-on-null case differs from SQL because PHP in_array(null, [""]) is loose.
🎲 Appwrite version
2.3.0
💻 Operating system
Linux (Debian 12), Docker
🧱 Your Environment
Self-hosted Appwrite 2.3.0, Postgres adapter (PostgreSQL 18), two API nodes.
💡 Suggested fix
In documentMatchesFilters() add the missing query operators (notStartsWith, notEndsWith, notContains, notBetween, notSearch, search, or, and), use strict comparison for equal/notEqual, and treat any still-unknown method as "not matched" (return false) or raise instead of defaulting to true.
👀 Have you spent some time to check if this issue has been raised before?
- I checked and didn't find a similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct
Activity
Prakhar0136 commentedon Oct 8, 2026
Hi! I would like to work on this issue. I have been looking into the transaction bulk Update behavior and would like to try fixing it if it’s still reproducible. Would it be okay if I take this one?
SahilArate commentedon Oct 8, 2026
Hi I’d like to work on this and have started. I reproduced it against current main: documentMatchesFilters() has no default branch and no cases for notStartsWith, notEndsWith, notContains, notBetween, and, or, containsAny and containsAll, so each of them matches every row already in the transaction state.
My plan is to add those operators (recursing for and/or), make equal/notEqual null-safe, and make unknown operators return false instead of matching everything. I’ll add unit tests through applyBulkUpdateToState() and applyBulkDeleteToState().
One question: for operators that can’t be evaluated in memory (search, notSearch, regex), would you prefer returning false (row is skipped) or throwing an exception? I’ll go with false unless you tell me otherwise. Could you assign this to me? I’ll open the PR against main
fix: handle missing query operators in transaction state filters