When i try to access one of my table, i got a server error
This happen with only ONE of my table, the other is fully working without any problem.
Any idea on how i can resolve this?
Failure Logs
SequelizeDatabaseError: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '*) AS count FROM db_mcs AS dbMcs’ at line 1
at Query.formatError (C:\laragon\www\VHC\node_modules\sequelize\lib\dialects\mysql\query.js:243:16)
at Query.handler [as onResult] (C:\laragon\www\VHC\node_modules\sequelize\lib\dialects\mysql\query.js:50:23)
at Query.execute (C:\laragon\www\VHC\node_modules\mysql2\lib\commands\command.js:30:14)
at Connection.handlePacket (C:\laragon\www\VHC\node_modules\mysql2\lib\connection.js:408:32)
at PacketParser.onPacket (C:\laragon\www\VHC\node_modules\mysql2\lib\connection.js:70:12)
at PacketParser.executeStart (C:\laragon\www\VHC\node_modules\mysql2\lib\packet_parser.js:75:16)
at Socket. (C:\laragon\www\VHC\node_modules\mysql2\lib\connection.js:77:25)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
Context
Please provide any relevant information about your setup.
Hi @j.cange, welcome to the Forest Admin community
I guess the name of the table that does not display properly is db_mcs.
Could you share the DDL of the table to let us investigate with a similar table?
Do you have the full SQL query that fails in your server logs?
About the full SQL query, you can add the NODE_ENV=development environment variable in your .env file, it should activate the SQL queries logs once your server restarted.
About the DDL, it is basically the set of SQL instructions that builds you table structure (name, columns, types, indexes,…). If you don’t know how to find that, a screenshot of the table definition could also help.
I’ve added the NODE_ENV variable to my .env i get the same message with extra informations :
[forest] ƒî│ƒî│ƒî│ Unexpected error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') AS count FROM db_mcs AS dbMcs’ at line 1
SequelizeDatabaseError: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') AS count FROM db_mcs AS dbMcs’ at line 1
at Query.formatError (C:\laragon\www\VHC\node_modules\sequelize\lib\dialects\mysql\query.js:243:16)
at Query.handler [as onResult] (C:\laragon\www\VHC\node_modules\sequelize\lib\dialects\mysql\query.js:50:23)
at Query.execute (C:\laragon\www\VHC\node_modules\mysql2\lib\commands\command.js:30:14)
at Connection.handlePacket (C:\laragon\www\VHC\node_modules\mysql2\lib\connection.js:408:32)
at PacketParser.onPacket (C:\laragon\www\VHC\node_modules\mysql2\lib\connection.js:70:12)
at PacketParser.executeStart (C:\laragon\www\VHC\node_modules\mysql2\lib\packet_parser.js:75:16)
at Socket. (C:\laragon\www\VHC\node_modules\mysql2\lib\connection.js:77:25)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
From previous event:
at Query.run (C:\laragon\www\VHC\node_modules\sequelize\lib\dialects\mysql\query.js:39:12)
at C:\laragon\www\VHC\node_modules\sequelize\lib\sequelize.js:641:29
From previous event:
at C:\laragon\www\VHC\node_modules\sequelize\lib\sequelize.js:641:12
From previous event:
at C:\laragon\www\VHC\node_modules\sequelize\lib\sequelize.js:637:10
at C:\laragon\www\VHC\node_modules\retry-as-promised\index.js:70:21
at new Promise ()
at retryAsPromised (C:\laragon\www\VHC\node_modules\retry-as-promised\index.js:60:10)
at C:\laragon\www\VHC\node_modules\sequelize\lib\sequelize.js:627:30
From previous event:
at Sequelize.query (C:\laragon\www\VHC\node_modules\sequelize\lib\sequelize.js:576:23)
at QueryInterface.rawSelect (C:\laragon\www\VHC\node_modules\sequelize\lib\query-interface.js:1160:27)
at Function.aggregate (C:\laragon\www\VHC\node_modules\sequelize\lib\model.js:1990:32)
at C:\laragon\www\VHC\node_modules\sequelize\lib\model.js:2042:19
at processImmediate (internal/timers.js:456:21)
From previous event:
at Function.count (C:\laragon\www\VHC\node_modules\sequelize\lib\model.js:2026:8)
at C:\laragon\www\VHC\node_modules\forest-express-sequelize\dist\services\resources-getter.js:357:30
[forest] ƒî│ƒî│ƒî│ Unexpected error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' *) AS `count` FROM `db_mcs` AS `dbMcs` ’ at line 1*
you should have the full SQL query that fails.
That is really strange that you can’t see it in your server console.
Can you run this SQL query directly in your database and try to find what’s wrong with it?
I guess: SELECT count(*) AS count FROM db_mcs;
should works right?
I just pulled a docker database using mariadb and generated a lumber project, and I’m sadly not able to reproduce your issue.
This is weird to me though, since running SELECT COUNT(*) FROM foo; works fine on mariadb, but SELECT COUNT(foo.*) FROM foo; does not.
Also, I would suggest to try specifying the sequelize dialect to mariadb inside the models/index.js of your project, just in case this would help (But since I’m not able to reproduce, I cannot check if it would help or not). You can see the syntax here
So i’ve followed your link and i managed to specify the dialect. Now the log return the same error as previously but with a little more info :
sql: SELECT count(dbMcs.*) AS count FROM db_mcs AS dbMcs; - parameters:[ ]
The “Parameters:[ ]” is new …
Something strange is that, i have another table in this database and i can access it without any problem :
Executing (default): SELECT count(employees.ID) AS count FROM employees AS employees;
GET /forest/employees/count?fields%5Bemployees%5D=accessLevel%2Cemail%2Cid%2Cpass&searchExtended=0&timezone=Europe%2FBrussels 304 - - 16.592 ms
If the dialect does not fix your issue, I think you should remove it.
Since I cannot reproduce your issue, could you answer a few question related to your DBMS :
Could you tell me which version of mariadb you are using ?
Is there any specific configuration related to that particular table ?
Are you using a all-in-one software (Like MAMP/LAMP/WAMP) to host your database (From the stack trace it looks like it, but I just want to be sure) ?