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

MySQL multiple ER_PARSE_ERROR #70

Open
ZRunner opened this issue Jul 9, 2020 · 1 comment
Open

MySQL multiple ER_PARSE_ERROR #70

ZRunner opened this issue Jul 9, 2020 · 1 comment

Comments

@ZRunner
Copy link

ZRunner commented Jul 9, 2020

I just decided for the first time to use a way to store express sessions with my already-existing database, which uses MariaDB version 10.1.44.

First of all, I experienced the #50 issue despite having the correct package version (1.7.3). I created the table myself, to avoid this error, following the instructions in #38.

And now, when I edit a session in my code (a basic thing like req.session.test = "123"), I face the nice error saying (node:25462) Error: ER_PARSE_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 '-translator (sid, expired, sess) values ('h4aCPnBIR_GWjqMSAvUj7gmt5u2zJZ0F', '20' at line 1

Full trace here:

[ERROR]  (node:25462) UnhandledPromiseRejectionWarning: Error: ER_PARSE_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 '-translator (sid, expired, sess) values ('h4aCPnBIR_GWjqMSAvUj7gmt5u2zJZ0F', '20' at line 1
    at Query.Sequence._packetToError (myfolder/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Query.ErrorPacket (myfolder/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
    at Protocol._parsePacket (myfolder/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (myfolder/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (myfolder/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (myfolder/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (myfolder/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (myfolder/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:304:12)
    at readableAddChunk (_stream_readable.js:280:9)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
    --------------------
    at Protocol._enqueue (myfolder/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Connection.query (myfolder/node_modules/mysql/lib/Connection.js:198:25)
    at myfolder/node_modules/knex/lib/dialects/mysql/index.js:135:18
    at new Promise (<anonymous>)
    at Client_MySQL._query (myfolder/node_modules/knex/lib/dialects/mysql/index.js:129:12)
    at Client_MySQL.query (myfolder/node_modules/knex/lib/client.js:169:17)
    at Runner.query (myfolder/node_modules/knex/lib/runner.js:134:36)
    at myfolder/node_modules/knex/lib/runner.js:40:23
    at myfolder/node_modules/knex/lib/runner.js:260:24
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

I need to quickly start working on sessions, so if you have any idea about how to resolve that... thanks!

@ZRunner
Copy link
Author

ZRunner commented Jul 10, 2020

Ok so after some tests, it looks like the lib doesn't handle properly table names, so if the name contains a - like mine, the query will return a parsing error. After removing the dash from my table name, that seems to work fine.

A fix would be to add `...` around table names when doing queries, to prevent this kind of issues. Not sure if it's something from this lib or only knex.js tbh.

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

1 participant