mariano / node-db-mysql

MySQL database bindings for Node.js
http://nodejsdb.org
150 stars 30 forks source link

delete chained method fails #64

Open shelleyp opened 12 years ago

shelleyp commented 12 years ago

The delete chained method fails. The following:

var sql = qry.delete('nodetest2') .where('id = ?', [4]) .sql();

Generates the following SQL, which is in error:

DELETE nodetest2 WHERE id = ?

ZhangYiJiang commented 12 years ago

To elaborate, the correct MySQL syntax for deleting from a single table is

DELETE FROM `table_name` WHERE row = value

Whereas the code currently only seems to produce

DELETE `table_name` WHERE row = value

when delete('table_name') is used. The relevant lines in the test that needs to be modified is 605 and 610 - a FROM needs to be added after the DELETE. I think the change could be as simple as editing L381 from query.cc to include the FROM, but I'm not familiar enough with the code to make the change