Repository navigation
fix: copy cordova query rows affected into query result - #10873
Conversation
WalkthroughCordovaQueryRunner now assigns Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant CordovaQueryRunner
participant CordovaDriver as Driver
Caller->>CordovaQueryRunner: execute SQL (non-insert)
CordovaQueryRunner->>Driver: runRawQuery(...)
Driver-->>CordovaQueryRunner: raw { rows, rowsAffected, ... }
alt previously
CordovaQueryRunner->>Caller: result { records, raw }
else now
CordovaQueryRunner->>Caller: result { records, raw, affected: raw.rowsAffected }
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/driver/cordova/CordovaQueryRunner.ts (1)
103-104: Consider settingresult.affectedfor INSERT queries too.For consistency with the non-INSERT branch and standard SQL driver behavior, INSERT queries should also propagate the affected row count.
Apply this diff to set
result.affectedin the INSERT branch:if (query.substr(0, 11) === "INSERT INTO") { result.raw = raw.insertId + result.affected = raw.rowsAffected } else {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/driver/cordova/CordovaQueryRunner.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: tests-linux (18) / postgres (14)
- GitHub Check: tests-linux (18) / mysql_mariadb
- GitHub Check: tests-linux (18) / sqlite
- GitHub Check: tests-linux (18) / mssql
- GitHub Check: tests-linux (20) / sqlite
- GitHub Check: tests-linux (20) / better-sqlite3
- GitHub Check: tests-linux (20) / oracle
- GitHub Check: tests-linux (20) / sap
- GitHub Check: tests-linux (20) / postgres (17)
- GitHub Check: tests-linux (20) / postgres (14)
- GitHub Check: tests-linux (20) / sqljs
- GitHub Check: tests-linux (20) / mssql
- GitHub Check: tests-linux (20) / mongodb
- GitHub Check: tests-linux (20) / mysql_mariadb
- GitHub Check: tests-windows / sqlite
- GitHub Check: tests-linux (20) / mysql_mariadb_latest
- GitHub Check: tests-linux (20) / cockroachdb
- GitHub Check: tests-windows / sqljs
- GitHub Check: tests-windows / better-sqlite3
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
src/driver/cordova/CordovaQueryRunner.ts (1)
113-113: Good addition for capturing affected rows.This correctly propagates the
rowsAffectedfrom the Cordova SQLite result to theQueryResultobject, which is essential for UPDATE and DELETE operations.
gioboa
left a comment
There was a problem hiding this comment.
Can you create a test to double check the fix please?
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/driver/cordova/CordovaQueryRunner.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
- GitHub Check: tests-linux (20) / postgres (17)
- GitHub Check: tests-linux (18) / oracle
- GitHub Check: tests-linux (18) / sap
- GitHub Check: tests-linux (20) / mssql
- GitHub Check: tests-linux (20) / cockroachdb
- GitHub Check: tests-linux (20) / mongodb
- GitHub Check: tests-linux (18) / sqljs
- GitHub Check: tests-linux (18) / mysql_mariadb
- GitHub Check: tests-linux (18) / mssql
- GitHub Check: tests-linux (18) / mongodb
- GitHub Check: tests-linux (18) / postgres (17)
- GitHub Check: tests-linux (18) / sqlite
- GitHub Check: tests-linux (18) / postgres (14)
- GitHub Check: tests-linux (18) / better-sqlite3
- GitHub Check: tests-linux (18) / mysql_mariadb_latest
- GitHub Check: tests-windows / better-sqlite3
- GitHub Check: tests-windows / sqljs
- GitHub Check: tests-windows / sqlite
- GitHub Check: Analyze (javascript-typescript)
|
|
||
| result.records = resultSet | ||
| result.raw = resultSet | ||
| result.affected = raw.rowsAffected |
There was a problem hiding this comment.
🧩 Analysis chain
Good fix for non-INSERT queries; verify INSERT and cross-driver consistency.
The assignment correctly populates result.affected with the row count for UPDATE, DELETE, and other non-INSERT queries, directly addressing issue #7374.
However, consider two points:
-
INSERT queries (lines 103-104) don't set
result.affected. INSERT statements typically affect exactly one row (or more in batch inserts), soresult.affected = raw.rowsAffectedshould probably be set there as well for consistency. -
Other SQLite drivers – verify that sibling drivers (e.g.,
SqliteQueryRunner,BetterSqlite3QueryRunner, or others extendingAbstractSqliteQueryRunner) also populateresult.affectedconsistently. If they don't, this fix should be applied across all SQLite-based drivers.
Run the following script to check how other SQLite drivers handle result.affected:
🏁 Script executed:
#!/bin/bash
# Description: Check if other SQLite-based query runners populate result.affected
# Find all files that extend AbstractSqliteQueryRunner or contain similar query logic
fd -e ts -e js . src/driver | xargs rg -n -C5 'result\.affected'Length of output: 14850
Set result.affected for INSERT queries as well to match other SQLite drivers.
The fix correctly addresses the reported issue for UPDATE, DELETE, and other non-INSERT queries. However, verification shows an inconsistency:
- INSERT queries (lines 103–104) don't populate
result.affected, while all other SQLite drivers in the codebase (SqliteQueryRunner, BetterSqlite3QueryRunner, ExpoQueryRunner, ReactNativeQueryRunner, CapacitorQueryRunner, SqljsQueryRunner) set it for all query types.
Add the same assignment to the INSERT branch (after line 104):
result.affected = raw.rowsAffected
This ensures Cordova's behavior aligns with other SQLite-based drivers and completes the fix for issue #7374 across all query types.
🤖 Prompt for AI Agents
In src/driver/cordova/CordovaQueryRunner.ts around line 113, the INSERT branch
currently does not set result.affected while other SQLite drivers do; add a line
after the INSERT handling (after line 104/around 113) to assign result.affected
= raw.rowsAffected so INSERT queries populate affected rows just like
UPDATE/DELETE and match behavior of other SQLite-based drivers.
@gioboa It doesn't seem there are any cordova tests or test infrastructure? What would you suggest? |
PR Code Suggestions ✨Latest suggestions up to 5630c33
Previous suggestionsSuggestions up to commit afd0577
|
||||||||||||||||||
|
We don't have tests for all drivers. In case of Cordova, we rely on community support mostly. If anyone is interested to setup testing for drivers we don't have tests yet, please get in touch with us on our discord channel. |
Close #7374
Cordova driver needs to copy query rows affected into query result
Summary by CodeRabbit