2016-09-26 09:28:47 +00:00
|
|
|
|
2022-06-06 08:53:59 +00:00
|
|
|
var Dml = require('./dml');
|
2016-09-26 09:28:47 +00:00
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
/**
|
|
|
|
* The equivalent of a SQL update.
|
2022-05-26 06:08:31 +00:00
|
|
|
*/
|
2022-06-06 08:53:59 +00:00
|
|
|
module.exports = new Class({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Dml
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-06-06 08:53:59 +00:00
|
|
|
,render: function(params) {
|
2022-05-30 01:30:33 +00:00
|
|
|
var sql = 'UPDATE'
|
2022-06-06 08:53:59 +00:00
|
|
|
+ this.renderTarget(params)
|
2022-05-30 01:30:33 +00:00
|
|
|
+ ' SET ';
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-06-06 08:53:59 +00:00
|
|
|
this.field.forEach(function(field, i) {
|
2022-05-30 01:30:33 +00:00
|
|
|
if (i > 0)
|
2015-01-23 13:09:30 +00:00
|
|
|
sql += ', ';
|
2022-05-30 01:30:33 +00:00
|
|
|
|
2022-06-06 08:53:59 +00:00
|
|
|
sql += field.render(params)
|
2022-05-30 01:30:33 +00:00
|
|
|
+ ' = '
|
|
|
|
+ this.expr[i].render(params);
|
|
|
|
}, this);
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-06-06 08:53:59 +00:00
|
|
|
sql += this.renderIfSet(this.where, 'WHERE', params)
|
2022-05-30 01:30:33 +00:00
|
|
|
+ this.renderLimit(params);
|
2015-01-23 13:09:30 +00:00
|
|
|
return sql;
|
|
|
|
}
|
|
|
|
});
|