transistorsoft / background-geolocation-console

A field-testing & analysis server for the Background Geolocation plugin
MIT License
150 stars 157 forks source link

SequelizeDatabaseError: SQLITE_ERROR #95

Closed wanschi closed 4 years ago

wanschi commented 4 years ago

Hi, Chris,

we are currently testing the console in conjunction with our app. Starting the server works, but the location POST request of the React Native SDK throws us the following error during the request to the server:

[0] POST /locations/DD 200 441.967 ms - 16 [0] Executing (default): SELECT id, device_id, device_model, company_id, company_token, framework FROM devices AS devices ORDER BY devices.updated_at DESC NULLS LAST, devices.created_at DESC NULLS LAST; [0] /devices { SequelizeDatabaseError: SQLITE_ERROR: near "NULLS": syntax error [0] at Query.formatError (/Users/Daniel/Daniel/_BRIVE/_DEVELOPMENT/background-geolocation-console/node_modules/sequelize/lib/dialects/sqlite/query.js:422:16) [0] at Query._handleQueryResponse (/Users/Daniel/Daniel/_BRIVE/_DEVELOPMENT/background-geolocation-console/node_modules/sequelize/lib/dialects/sqlite/query.js:73:18) [0] at afterExecute (/Users/Daniel/Daniel/_BRIVE/_DEVELOPMENT/background-geolocation-console/node_modules/sequelize/lib/dialects/sqlite/query.js:250:31) [0] at replacement (/Users/Daniel/Daniel/_BRIVE/_DEVELOPMENT/background-geolocation-console/node_modules/sqlite3/lib/trace.js:19:31) [0] at Statement.errBack (/Users/Daniel/Daniel/_BRIVE/_DEVELOPMENT/background-geolocation-console/node_modules/sqlite3/lib/sqlite3.js:16:21) [0] name: 'SequelizeDatabaseError', [0] parent: [0] { Error: SQLITE_ERROR: near "NULLS": syntax error [0] errno: 1, [0] code: 'SQLITE_ERROR', [0] sql: [0] 'SELECT id, device_id, device_model, company_id, company_token, framework FROM devices AS devices ORDER BY devices.updated_at DESC NULLS LAST, devices.created_at DESC NULLS LAST;' }, [0] original: [0] { Error: SQLITE_ERROR: near "NULLS": syntax error [0] errno: 1, [0] code: 'SQLITE_ERROR', [0] sql: [0] 'SELECT id, device_id, device_model, company_id, company_token, framework FROM devices AS devices ORDER BY devices.updated_at DESC NULLS LAST, devices.created_at DESC NULLS LAST;' }, [0] sql: [0] 'SELECT id, device_id, device_model, company_id, company_token, framework FROM devices AS devices ORDER BY devices.updated_at DESC NULLS LAST, devices.created_at DESC NULLS LAST;', [0] parameters: undefined } `

In general, the whole database connection doesn't seem to work. We are using SQL Lite.

npm run test fails:

FAIL tests/site-api.test.js (8.233s) site api ✓ /company_tokens (395ms) ✓ /stats (794ms) devices ✕ /devices (115ms) ✓ DELETE /devices/test (475ms) locations ✕ /locations/latest (55ms) ✓ POST /locations (484ms) ✓ POST /locations [] (269ms) ✕ /locations (152ms) ✓ POST /locations/test (275ms) ✓ DELETE /locations (19ms)

● site api › devices › /devices

Expected value   200
Received:
  500

Message:
  expected { Object (_events, _eventsCount, ...) } to have status code 200 but got 500

  32 |         .get('/api/site/devices?company_token=test');
  33 | 
> 34 |       expect(res).have.status(200);
     |                        ^
  35 |       expect(res).to.be.json;
  36 |     });
  37 | 

  at _callee3$ (tests/site-api.test.js:34:24)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at invoke (node_modules/regenerator-runtime/runtime.js:135:20)
  at node_modules/regenerator-runtime/runtime.js:145:13

● site api › locations › /locations/latest

Expected value   200
Received:
  500

Message:
  expected { Object (_events, _eventsCount, ...) } to have status code 200 but got 500

  49 |       const res = await chai.request(server)
  50 |         .get('/api/site/locations/latest?company_token=test');
> 51 |       expect(res).have.status(200);
     |                        ^
  52 |       expect(res).to.be.json;
  53 |     });
  54 | 

  at _callee5$ (tests/site-api.test.js:51:24)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at invoke (node_modules/regenerator-runtime/runtime.js:135:20)
  at node_modules/regenerator-runtime/runtime.js:145:13

● site api › locations › /locations

Expected value   200
Received:
  500

Message:
  expected { Object (_events, _eventsCount, ...) } to have status code 200 but got 500

  73 |         .get('/api/site/locations?company_token=test&device_id=372');
  74 | 
> 75 |       expect(res).have.status(200);
     |                        ^
  76 |       expect(res).to.be.json;
  77 |       expect(res.body).to.be.an('array');
  78 |       // console.info('locations:data', res.body);

  at _callee8$ (tests/site-api.test.js:75:24)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at invoke (node_modules/regenerator-runtime/runtime.js:135:20)
  at node_modules/regenerator-runtime/runtime.js:145:13

FAIL tests/api.test.js (8.634s) jwt api ✓ /register (305ms) ✓ /register without device info (9ms) ✓ /company_tokens (24ms) ✓ /company_tokens 403 (11ms) ✓ /refresh_token (380ms) ✓ /refresh_token 403 (50ms) ✓ /stats (129ms) ✓ /stats 403 (5ms) ✕ /devices (113ms) ✓ /devices 403 (219ms) locations ✕ /locations/latest (188ms) ✓ POST /locations (249ms) ✓ POST /locations [] (176ms) ✕ /locations (158ms) ✓ POST /locations/test (31ms) ✓ DELETE /locations (257ms)

● jwt api › /devices

Expected value   200
Received:
  500

Message:
  expected { Object (_events, _eventsCount, ...) } to have status code 200 but got 500

  93 |       .get('/api/devices')
  94 |       .set('Authorization', 'Bearer ' + token);
> 95 |     expect(res).have.status(200);
     |                      ^
  96 |     expect(res).to.be.json;
  97 |     // console.info('devices:data', res.body);
  98 |   });

  at _callee10$ (tests/api.test.js:95:22)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at invoke (node_modules/regenerator-runtime/runtime.js:135:20)
  at node_modules/regenerator-runtime/runtime.js:145:13

● jwt api › locations › /locations/latest

Expected value   200
Received:
  500

Message:
  expected { Object (_events, _eventsCount, ...) } to have status code 200 but got 500

  112 |         .get('/api/locations/latest')
  113 |         .set('Authorization', 'Bearer ' + token);
> 114 |       expect(res).have.status(200);
      |                        ^
  115 |       expect(res).to.be.json;
  116 |     });
  117 | 

  at _callee12$ (tests/api.test.js:114:24)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at invoke (node_modules/regenerator-runtime/runtime.js:135:20)
  at node_modules/regenerator-runtime/runtime.js:145:13

● jwt api › locations › /locations

Expected value   200
Received:
  500

Message:
  expected { Object (_events, _eventsCount, ...) } to have status code 200 but got 500

  138 |         .get('/api/locations')
  139 |         .set('Authorization', 'Bearer ' + token);
> 140 |       expect(res).have.status(200);
      |                        ^
  141 |       expect(res).to.be.json;
  142 |       expect(res.body).to.be.an('array');
  143 |       // console.info('locations:data', res.body);

  at _callee15$ (tests/api.test.js:140:24)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at invoke (node_modules/regenerator-runtime/runtime.js:135:20)
  at node_modules/regenerator-runtime/runtime.js:145:13

Test Suites: 2 failed, 2 total Tests: 6 failed, 20 passed, 26 total Snapshots: 0 total Time: 15.319s

Sigura commented 4 years ago

Thank you for details.

fix merged to master