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

update_batch not working with where clause #23

Closed
arifjaunpur opened this issue May 28, 2018 · 2 comments
Closed

update_batch not working with where clause #23

arifjaunpur opened this issue May 28, 2018 · 2 comments
Labels
Milestone

Comments

@arifjaunpur
Copy link

whenever we pass where condition in .update_batch(table,dataset,index[,where],callback), it throws following error

[ { Error: ER_PARSE_ERROR: 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 'WHERE `id` = 30 AND `tripId` IN (30,30)' at line 1
    at Query.Sequence._packetToError (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/sequences/Sequence.js:52:14)
    at Query.ErrorPacket (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/sequences/Query.js:77:18)
    at Protocol._parsePacket (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/Protocol.js:279:23)
    at Parser.write (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/Parser.js:76:12)
    at Protocol.write (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.<anonymous> (/home/mohd/app/express-test/node_modules/mysql/lib/Connection.js:103:28)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    --------------------
    at Protocol._enqueue (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/Protocol.js:145:48)
    at Connection.query (/home/mohd/app/express-test/node_modules/mysql/lib/Connection.js:208:25)
    at exec (/home/mohd/app/express-test/node_modules/node-querybuilder/drivers/mysql/query_exec.js:11:18)
    at next_batch (/home/mohd/app/express-test/node_modules/node-querybuilder/drivers/mysql/query_exec.js:151:17)
    at Object.update_batch (/home/mohd/app/express-test/node_modules/node-querybuilder/drivers/mysql/query_exec.js:169:15)
    at Object.<anonymous> (/home/mohd/app/express-test/b.js:26:17)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    code: 'ER_PARSE_ERROR',
    errno: 1064,
    sqlMessage: '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 \'WHERE `id` = 30 AND `tripId` IN (30,30)\' at line 1',
    sqlState: '42000',
    index: 0,
    sql: 'UPDATE (`trip_students_booking`) SET `studentId` = CASE WHEN `tripId` = 30 THEN 43 WHEN `tripId` = 30 THEN 42 ELSE `studentId` END WHERE  WHERE `id` = 30 AND `tripId` IN (30,30)' } ]

We can see that 2 times added where clause

@arifjaunpur
Copy link
Author

after fixing above issue in library, got another issue

/home/mohd/app/express-test/node_modules/mysql/lib/protocol/Parser.js:80
        throw err; // Rethrow non-MySQL errors
        ^

TypeError: Assignment to constant variable.
    at exec (/home/mohd/app/express-test/node_modules/node-querybuilder/drivers/mysql/query_exec.js:154:37)
    at Query.conn.query [as _callback] (/home/mohd/app/express-test/node_modules/node-querybuilder/drivers/mysql/query_exec.js:31:17)
    at Query.Sequence.end (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
    at Query._handleFinalResultPacket (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/sequences/Query.js:139:8)
    at Query.OkPacket (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/sequences/Query.js:72:10)
    at Protocol._parsePacket (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/Protocol.js:279:23)
    at Parser.write (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/Parser.js:76:12)
    at Protocol.write (/home/mohd/app/express-test/node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.<anonymous> (/home/mohd/app/express-test/node_modules/mysql/lib/Connection.js:103:28)
    at emitOne (events.js:116:13)

@kylefarris kylefarris added the bug label Jun 4, 2018
@kylefarris kylefarris added this to the v2 milestone Jun 21, 2018
kylefarris pushed a commit that referenced this issue Jul 26, 2018
@kylefarris
Copy link
Owner

This is officially working in the v2 branch.

kylefarris pushed a commit that referenced this issue Feb 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants