andpor / react-native-sqlite-storage

Full featured SQLite3 Native Plugin for React Native (Android and iOS)
MIT License
2.75k stars 521 forks source link

no such function: JSON_OBJECT #480

Closed gondooley closed 2 years ago

gondooley commented 3 years ago

Machine: Lenovo B50-10 (Intel Pentium CPU N3540 2.16GHz, 4GB RAM) OS: Windows 10 Home build 19041.1083 Test device: Samsung Galaxy A70 SM-A705FN/DS running Android 11

Steps taken on laptop 1) npx react-native init AwesomeProject 2) cd .\AwesomeProject\ 3) npm install --save react-native-sqlite-storage 4) npm install --save deprecated-react-native-listview 5) Replaced AwesomeProject/index.js text with text from AwesomeProject/node_modules/react-native-sqlite-storage/test/index.android.json1.js 6) npx react-native run-android (Build successful and app appears on mobile device)

On mobile device 7) Press "Run Demo"

Result Screenshot_20210715-151000_AwesomeProject

Comments

Full Metro log

LOG Callback based runtime ready LOG Running "AwesomeProject" with {"rootTag":1} LOG OPEN database: Test.db LOG SQLite.open({"name":"Test.db","dblocation":"nosync"}) LOG new transaction is waiting for open operation LOG SQLite.backgroundExecuteSqlBatch({"dbargs":{"dbname":"Test.db"},"executes":[{"qid":1111,"sql":"SELECT 1","params":[]},{"qid":1111,"sql":"SELECT 1 FROM Version LIMIT 1","params":[]}]}) LOG received version error: {"code": 0, "message": "no such table: Version (code 1 SQLITE_ERROR[1]): , while compiling: SELECT 1 FROM Version LIMIT 1"} LOG warning - exception while invoking a callback: {"code":0,"line":109240,"column":27,"sourceURL":"http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.awesomeproject&modulesOnly=false&runModule=true"} LOG all config SQL done LOG SQLite.backgroundExecuteSqlBatch({"dbargs":{"dbname":"Test.db"},"executes":[{"qid":1111,"sql":"BEGIN","params":[]},{"qid":1111,"sql":"DROP TABLE IF EXISTS Employees;","params":[]},{"qid":1111,"sql":"DROP TABLE IF EXISTS Offices;","params":[]},{"qid":1111,"sql":"DROP TABLE IF EXISTS Departments;","params":[]},{"qid":1111,"sql":"CREATE TABLE IF NOT EXISTS Version( version_id INTEGER PRIMARY KEY NOT NULL); ","params":[]},{"qid":1111,"sql":"CREATE TABLE IF NOT EXISTS Departments( department_id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(30) ); ","params":[]},{"qid":1111,"sql":"CREATE TABLE IF NOT EXISTS Offices( office_id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(20), longtitude FLOAT, latitude FLOAT ) ; ","params":[]},{"qid":1111,"sql":"CREATE TABLE IF NOT EXISTS Employees( employe_id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(55), office INTEGER, department INTEGER, custom_info TEXT DEFAULT \"\",FOREIGN KEY ( office ) REFERENCES Offices ( office_id ) FOREIGN KEY ( department ) REFERENCES Departments ( department_id ));","params":[]},{"qid":1111,"sql":"INSERT INTO Departments (name) VALUES (\"Client Services\");","params":[]},{"qid":1111,"sql":"INSERT INTO Departments (name) VALUES (\"Investor Services\");","params":[]},{"qid":1111,"sql":"INSERT INTO Departments (name) VALUES (\"Shipping\");","params":[]},{"qid":1111,"sql":"INSERT INTO Departments (name) VALUES (\"Direct Sales\");","params":[]},{"qid":1111,"sql":"INSERT INTO Offices (name, longtitude, latitude) VALUES (\"Denver\", 59.8, 34.);","params":[]},{"qid":1111,"sql":"INSERT INTO Offices (name, longtitude, latitude) VALUES (\"Warsaw\", 15.7, 54.);","params":[]},{"qid":1111,"sql":"INSERT INTO Offices (name, longtitude, latitude) VALUES (\"Berlin\", 35.3, 12.);","params":[]},{"qid":1111,"sql":"INSERT INTO Offices (name, longtitude, latitude) VALUES (\"Paris\", 10.7, 14.);","params":[]},{"qid":1111,"sql":"INSERT INTO Employees (name, office, department, custom_info) VALUES (\"Sylvester Stallone\", 2, 4, '{\"known\": true}')","params":[]},{"qid":1111,"sql":"INSERT INTO Employees (name, office, department, custom_info) VALUES (\"Elvis Presley\", 2, 4, '{\"known\": true}')","params":[]},{"qid":1111,"sql":"INSERT INTO Employees (name, office, department, custom_info) VALUES (\"Leslie Nelson\", 3, 4, '{\"known\": true}')","params":[]},{"qid":1111,"sql":"INSERT INTO Employees (name, office, department, custom_info) VALUES (\"Fidel Castro\", 3, 3, '{\"known\": true}')","params":[]},{"qid":1111,"sql":"INSERT INTO Employees (name, office, department, custom_info) VALUES (\"Bill Clinton\", 1, 3, '{\"known\": false}')","params":[]},{"qid":1111,"sql":"INSERT INTO Employees (name, office, department, custom_info) VALUES (\"Margaret Thatcher\", 1, 3, '{\"known\": true}')","params":[]},{"qid":1111,"sql":"INSERT INTO Employees (name, office, department, custom_info) VALUES (\"Donald Trump\", 2, 4, '{\"known\": true, \"impeached\": true}')","params":[]},{"qid":1111,"sql":"INSERT INTO Employees (name, office, department, custom_info) VALUES (\"Dr DRE\", 2, 2, '{\"known\": true}')","params":[]},{"qid":1111,"sql":"INSERT INTO Employees (name, office, department, custom_info) VALUES (\"Samantha Fox\", 2, 1, '{\"known\": true}')","params":[]}]}) LOG SQL executed ... LOG SQL executed ... LOG SQL executed ... LOG SQLite.backgroundExecuteSqlBatch({"dbargs":{"dbname":"Test.db"},"executes":[{"qid":1111,"sql":"COMMIT","params":[]}]}) LOG Executing JSON1 queries... LOG SQLite.backgroundExecuteSqlBatch({"dbargs":{"dbname":"Test.db"},"executes":[{"qid":1111,"sql":"BEGIN","params":[]},{"qid":1111,"sql":"SELECT JSON_OBJECT('name', e.name, 'office_id', e.office, 'department_id', e.department) AS data FROM Employees e","params":[]}]}) LOG error: {"code": 0, "message": "no such function: JSON_OBJECT (code 1 SQLITE_ERROR[1]): , while compiling: SELECT JSON_OBJECT('name', e.name, 'office_id', e.office, 'department_id', e.department) AS data FROM Employees e"} LOG SQLite.backgroundExecuteSqlBatch({"dbargs":{"dbname":"Test.db"},"executes":[{"qid":1111,"sql":"ROLLBACK","params":[]}]}) LOG error: {"code": 0, "message": "no such function: JSON_OBJECT (code 1 SQLITE_ERROR[1]): , while compiling: SELECT JSON_OBJECT('name', e.name, 'office_id', e.office, 'department_id', e.department) AS data FROM Employees e"}

andpor commented 2 years ago

JSON support is only for Android native SQLLite replacement, not for fundamental Android and iOS which rely on the device version of SQLite,

gondooley commented 2 years ago

JSON support is only for Android native SQLLite replacement, not for fundamental Android and iOS which rely on the device version of SQLite,

Thanks for the explanation, much appreciated!