Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no such function: JSON_OBJECT #480

Closed
gondooley opened this issue Jul 15, 2021 · 2 comments
Closed

no such function: JSON_OBJECT #480

gondooley opened this issue Jul 15, 2021 · 2 comments

Comments

@gondooley
Copy link

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

  • I had to add step (4) myself to get the thing to work
  • In Step(5) the README.md tells you to replace index.ios.js, which does not exist
  • While I'm here, rather than instructing users to replace the file, it may be clearer to tell them to replace the code in the file. Also, the README section on 'Opening a database' might be more helpfully titled 'Creating a database', or 'Opening a new database'

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
Copy link
Owner

andpor commented Oct 1, 2021

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

@andpor andpor closed this as completed Oct 1, 2021
@gondooley
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants