return`UPDATE ${this.quoteTable(tableName)} SET ${values.join(',')}${this.whereQuery(where,options)}`;
if(options.limit){
return`UPDATE ${this.quoteTable(tableName)} SET ${values.join(',')} WHERE rowid IN (SELECT rowid FROM ${this.quoteTable(tableName)}${this.whereQuery(where,options)} LIMIT ${this.escape(options.limit)})`;
}else{
return`UPDATE ${this.quoteTable(tableName)} SET ${values.join(',')}${this.whereQuery(where,options)}`;
* @param {Boolean} [options.sideEffects=true] Whether or not to update the side effects of any virtual setters.
* @param {Boolean} [options.sideEffects=true] Whether or not to update the side effects of any virtual setters.
* @param {Boolean} [options.individualHooks=false] Run before / after update hooks?. If true, this will execute a SELECT followed by individual UPDATEs. A select is needed, because the row data needs to be passed to the hooks
* @param {Boolean} [options.individualHooks=false] Run before / after update hooks?. If true, this will execute a SELECT followed by individual UPDATEs. A select is needed, because the row data needs to be passed to the hooks
* @param {Boolean} [options.returning=false] Return the affected rows (only for postgres)
* @param {Boolean} [options.returning=false] Return the affected rows (only for postgres)
* @param {Number} [options.limit] How many rows to update (only for mysql and mariadb, implemented as TOP(n) for MSSQL)
* @param {Number} [options.limit] How many rows to update (only for mysql and mariadb, implemented as TOP(n) for MSSQL; for sqlite it is supported only when rowid is present)
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @param {Boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging).
* @param {Boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging).
* @param {Transaction} [options.transaction] Transaction to run query under
* @param {Transaction} [options.transaction] Transaction to run query under