Error when using MariaDB as backend database
See original GitHub issueI was experimenting with sqlpad lately and everything was working fine up until the point when I decided to have standalone backend database for query history persistence. First DBMS I tried was MariaDB (simply because I had a spare one) and after I created separate schema for sqlpad there and pointed SQLPAD_BACKEND_DB_URI variable to it I was left with only auth working. Both schema browser and queries stopped working. In the logs of sqlpad I see that it’s trying to read something from batches table and failing:
{"level":20,"time":"2021-06-17T11:05:48.431Z","pid":1,"hostname":"51b5bfe1a4ad","name":"sqlpad-app","msg":"Executing (default): SELECT `id`, `query_id` AS `queryId`, `name`, `connection_id` AS `connectionId`, `connection_client_id` AS `connectionClientId`, `status`, `start_time` AS `startTime`, `stop_time` AS `stopTime`, `duration_ms` AS `durationMs`, `batch_text` AS `batchText`, `selected_text` AS `selectedText`, `chart`, `user_id` AS `userId`, `created_at` AS `createdAt`, `updated_at` AS `updatedAt` FROM `batches` AS `Batches` WHERE `Batches`.`id` = 'b762439e-0674-4325-8d69-1136b6376322';"}
{"level":50,"time":"2021-06-17T11:05:48.435Z","pid":1,"hostname":"51b5bfe1a4ad","name":"sqlpad-app","stack":"SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)
at /usr/app/node_modules/sequelize/lib/dialects/mariadb/query.js:186:72
at Array.map (<anonymous>)
at Query.handleJsonSelectQuery (/usr/app/node_modules/sequelize/lib/dialects/mariadb/query.js:185:21)
at Query.formatResults (/usr/app/node_modules/sequelize/lib/dialects/mariadb/query.js:130:12)
at Query.run (/usr/app/node_modules/sequelize/lib/dialects/mariadb/query.js:74:17)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /usr/app/node_modules/sequelize/lib/sequelize.js:619:16
at async MySQLQueryInterface.select (/usr/app/node_modules/sequelize/lib/dialects/abstract/query-interface.js:953:12)
at async Function.findAll (/usr/app/node_modules/sequelize/lib/model.js:1753:21)
at async Function.findOne (/usr/app/node_modules/sequelize/lib/model.js:1917:12)
at async Batches.findOneById (/usr/app/models/batches.js:16:17)
at async create (/usr/app/routes/batches.js:38:20)","type":"Error","msg":"Unexpected token o in JSON at position 1"}
Then I tried to use postgres as backend db and it worked perfectly fine! I see the same query from batches table except now it’s not failing:
{"level":20,"time":"2021-06-17T11:49:13.826Z","pid":1,"hostname":"49cf75db16ed","name":"sqlpad-app","msg":"Executing (default): SELECT \"id\", \"query_id\" AS \"queryId\", \"name\", \"connection_id\" AS \"connectionId\", \"connection_client_id\" AS \"connectionClientId\", \"status\", \"start_time\" AS \"startTime\", \"stop_time\" AS \"stopTime\", \"duration_ms\" AS \"durationMs\", \"batch_text\" AS \"batchText\", \"selected_text\" AS \"selectedText\", \"chart\", \"user_id\" AS \"userId\", \"created_at\" AS \"createdAt\", \"updated_at\" AS \"updatedAt\" FROM \"batches\" AS \"Batches\" WHERE \"Batches\".\"id\" = '6e2b517a-e508-4064-9bca-bb63dff94b87';"}
{"level":20,"time":"2021-06-17T11:49:13.832Z","pid":1,"hostname":"49cf75db16ed","name":"sqlpad-app","msg":"Executing (default): SELECT \"id\", \"query_id\" AS \"queryId\", \"name\", \"connection_id\" AS \"connectionId\", \"connection_client_id\" AS \"connectionClientId\", \"status\", \"start_time\" AS \"startTime\", \"stop_time\" AS \"stopTime\", \"duration_ms\" AS \"durationMs\", \"batch_text\" AS \"batchText\", \"selected_text\" AS \"selectedText\", \"chart\", \"user_id\" AS \"userId\", \"created_at\" AS \"createdAt\", \"updated_at\" AS \"updatedAt\" FROM \"batches\" AS \"Batches\" WHERE \"Batches\".\"id\" = '6e2b517a-e508-4064-9bca-bb63dff94b87';"}
I thought may be I misconfigured something in the first place so I decided to reproduce everything from scratch and… Managed to do that: combo of latest sqlpad docker image + latest mariadb docker image + SQLPAD_BACKEND_DB_URI pointing to that mariadb is definitely not working as it should.
Any ideas what could cause this behavior?
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (7 by maintainers)

Top Related StackOverflow Question
Wow that escalated quickly
Sequelize seems to be maintained again 🙌 Was able to get the changes in the fork back upstream https://github.com/sequelize/sequelize/pull/13633