Wappler 7.7.5, macOS 15.7.4
I encountered a console error in my capacitor project while sqlite paged query. When sorting is enabled in query. Without sorting there is no issue in query. I submitted the error to AI for a solution and received this response. Please check if it can be fixed from Wappler end.
Console Error:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'name')
at n (dmxCapacitorSQLite.js:7:1521)
at dmxCapacitorSQLite.js:7:3819
at Array.map (<anonymous>)
at dmxCapacitorSQLite.js:7:3786
at dmx.ast2sql (dmxCapacitorSQLite.js:7:3895)
at Capacitor.sqlite.paged (dmxCapacitorSQLite.js:7:6205)
at r._execStep (dmxAppConnect.js:9:35040)
at dmxAppConnect.js:9:34542.
AI Solution Found:
Fix TypeError in dmxCapacitorSQLite.js
The goal is to fix the TypeError: Cannot read properties of undefined (reading 'name') which occurs in the ast2sql function of dmxCapacitorSQLite.js.
Proposed Changes
Capacitor SQLite Plugin
[MODIFY]
dmxCapacitorSQLite.js
I will apply several fixes to the ast2sql function:
-
Null-safety for table name extraction: Update the
nfunction to safely accesstable.name.-
From:
function n(e){return a(e.table.name||e.table||t.table.name||t.table)} -
To:
function n(e){return a((e.table && e.table.name) || e.table || (t.table && t.table.name) || t.table)}
-
-
Null-safety for FROM clause: Update the
ofunction to safely accesst.table.name.-
From:
function o(t){return "FROM "+a(t.table.name||t.table)...} -
To:
function o(t){return "FROM "+a((t.table && t.table.name) || t.table)...}
-
-
Fix variable typos: In
groupBy.mapandorders.mapcallbacks, changen(i)ton(e). The variableirefers to a function, which is incorrect in this context;eis the current element in the map.-
groupBy.map((e=>(t.joins&&t.joins.length?n(i)+".":"")+a(e.column)))->groupBy.map((e=>(t.joins&&t.joins.length?n(e)+".":"")+a(e.column))) -
orders.map((e=>(t.joins&&t.joins.length?n(i)+".":"")+a(e.column)...))->orders.map((e=>(t.joins&&t.joins.length?n(e)+".":"")+a(e.column)...))
-
Verification Plan
Automated Tests
- I will create a small node script in
/tmp/verify_sqlite.jsthat mimics thedmx.ast2sqlfunction (since it's a pure function) and test it with various AST inputs, including those with missingtableproperties and with joins.
Manual Verification
- The user should run the application on an Android device (as reported) and verify that the error no longer appearing when performing SQLite operations.


