kylefarris / node-querybuilder

Node QueryBuilder Adapter for Node.js (tags: nodejs, node, mysql, active record, activerecord, querybuilder, query builder)
49 stars 19 forks source link

Problem with .DELETE() method #1

Closed gino8080 closed 9 years ago

gino8080 commented 9 years ago

Hello, first of all Great work!! :+1:

I was using mysql-active-records before, now switched to this and everything is better but NOT delete

every time I use DELETE the composed query has unnecessary parenthesis that give me SQL error something like:

//tried with:
 db .where( { UTOP_USER_K_ID : 3 } ).delete('user_topics','NULL', function(err, rows) {..
//also
db.delete('user_topics', { UTOP_USER_K_ID : 3 } , function(err, rows) {..
//also with from() the result is always :

"DELETE FROM (`user_topics`) WHERE `UTOP_USER_K_ID` = 3 " // --> SQL ERROR!

//this is ok:
"DELETE FROM `user_topics` WHERE `UTOP_USER_K_ID` = 3 " // --> SQL OK !

so I have to use the plain .query() method :(

any help with this?

thank you very much!

kylefarris commented 9 years ago

Hi Gino,

I've never actually seen that show up as an issue on my MySQL server, but, I don't see any reason why we would need the paranthesis--it's just how Codeigniter does it so I figured there was a good reason. You're welcome to make a pull request to fix the issue; otherwise, I'll have to get to it when I get a chance (working on some features and bug fixes on some other NPM modules at the moment... on top of my normal job).

Thanks for the bug report!

-Kyle

kylefarris commented 9 years ago

Nevermind, it was easy enough to fix. Patch is in commit: 31f97b4d0893a658c32ac0cbc1beede2d4ccd2da

I've updated the module in NPM to version 0.10.0--make sure you upgrade.

Thanks for the using the module!

-Kyle