question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ER_PARSE_ERROR in sub request

See original GitHub issue

I’m trying to send simple request with sub request, and I’m getting ER_PARSE_ERROR. This is my request:

“SELECT * FROM companies WHERE Name LIKE ‘%Пиво%’ AND Rate >= 3 AND Id IN (SELECT CompanyId FROM companydishtypes WHERE DishTypeId IN (1, 2, 3)) ORDER BY Rate DESC, Name ASC LIMIT 5”`

I tried to escape the column name and table name using? and ??. But nothing helped. At what, if I copy this request from my code and try to execute it through WorkBench, then this query is executed without errors and I get the correct result. What can I do wrong?

I hope additional info will be able to help. Connection:

 Name:  Local instance MySQL
 Host: localhost
 Port: 3306
 Server: MySQL Community Server (GPL)
 Version: 5.7.18-log
 Connector: C++ 1.1.4
 Login User: root
 Current User: root@localhost
 SSL: Disabled

Debug info from Node output console:

listening on 5001
Sat, 01 Jul 2017 11:08:49 GMT|POST|/api/companies/list|::1
<-- HandshakeInitializationPacket
HandshakeInitializationPacket {
  protocolVersion: 10,
  serverVersion: '5.7.18-log',
  threadId: 26,
  scrambleBuff1: <Buffer 1e 6a 57 58 4c 2e 13 2a>,
  filler1: <Buffer 00>,
  serverCapabilities1: 63487,
  serverLanguage: 33,
  serverStatus: 2,
  serverCapabilities2: 33279,
  scrambleLength: 21,
  filler2: <Buffer 00 00 00 00 00 00 00 00 00 00>,
  scrambleBuff2: <Buffer 31 2a 64 2f 0f 70 49 03 7f 10 1b 16>,
  filler3: <Buffer 00>,
  pluginData: 'mysql_native_password',
  protocol41: true }
--> ClientAuthenticationPacket
ClientAuthenticationPacket {
  clientFlags: 521167,
  maxPacketSize: 0,
  charsetNumber: 33,
  filler: undefined,
  user: 'root',
  scrambleBuff: <Buffer 9d 9c 20 42 22 96 49 8d 1b 8f c8 5a 31 6a b3 83 e7 e0 31 69>,
  database: 'food-delivery',
  protocol41: true }
<-- OkPacket
OkPacket {
  fieldCount: 0,
  affectedRows: 0,
  insertId: 0,
  serverStatus: 2,
  warningCount: 0,
  message: '',
  protocol41: true,
  changedRows: 0 }
--> ComQueryPacket
ComQueryPacket {
  command: 3,
  sql: 'SELECT * FROM `companies` WHERE Name LIKE \'%Пиво%\' AND Rate >= 3 AND Id IN (SELECT `CompanyId` FROM `companydishtypes` WHERE DishTypeId IN (1, 2, 3)) ORDER BY `Rate` DESC, `Name` ASC LIMIT 5' }
<-- ErrorPacket
ErrorPacket {
  fieldCount: 255,
  errno: 1064,
  sqlStateMarker: '#',
  sqlState: '42000',
  message: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'`companydishtypes` WHERE DishTypeId IN (1, 2, 3)) ORDER BY `Rate` DESC, `Name` A\' at line 1' }

Environment info:

Node.JS: 6.11.0 LTS
MySQLjs module: 2.13.0
OS: Windows 10 Pro x64 1703 build 15063.447

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
YevhenStienincommented, Jul 1, 2017

I replaced the mysqljs/mysql module with a mysql2 module. Apparently, they use the same parser to parse requests. But the result was the same. Most likely, I’m doing something wrong. But I need help.

0reactions
YevhenStienincommented, Jul 6, 2017

Thanks a lot, @dougwilson You helped me very much. I do not even know how I managed put this character instead of a space. =)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve parse error when HTTP content-type header is ...
Cause. The HTTP content-type header is missing in the request or response message.
Read more >
Formula Parse Errors In Google Sheets And How To Fix Them
Essentially, it means Google Sheets can't interpret your formula. It can't fulfill the formula request so it returns an error message. There are ......
Read more >
node.js - Parse Error on Nodejs POST request - Stack Overflow
Have a look at this question if you are passing it seemingly valid JSON. It could be that you're passing it as an...
Read more >
How To Fix The WordPress Parse Error Easily - Muffin Group
A WordPress parse error is serious. It will block access to the website and readers will not be able to view the content....
Read more >
Parse error with CSS custom properties with default values ...
As a workaround, disable postcss-calc in package.json to pass gatsby build in my case. "cssnano": { "preset" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found