mirror of
https://github.com/knex/knex.git
synced 2025-12-28 23:48:58 +00:00
parent
fbef9fcec7
commit
0a1976d8fd
@ -814,6 +814,12 @@ assign(Builder.prototype, {
|
||||
return this;
|
||||
},
|
||||
|
||||
// Remove everything from select clause
|
||||
clearOrder(){
|
||||
this._clearGrouping('order');
|
||||
return this;
|
||||
},
|
||||
|
||||
// Insert & Update
|
||||
// ------
|
||||
|
||||
|
||||
@ -77,6 +77,7 @@ export default [
|
||||
'pluck',
|
||||
'clearSelect',
|
||||
'clearWhere',
|
||||
'clearOrder',
|
||||
'insert',
|
||||
'update',
|
||||
'returning',
|
||||
|
||||
@ -413,6 +413,39 @@ describe("QueryBuilder", function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it("clear an order", function() {
|
||||
testsql(qb().table('users').orderBy('name', 'desc').clearOrder(), {
|
||||
mysql: {
|
||||
sql: 'select * from `users`'
|
||||
},
|
||||
mssql: {
|
||||
sql: 'select * from [users]'
|
||||
},
|
||||
postgres: {
|
||||
sql: 'select * from "users"'
|
||||
},
|
||||
redshift: {
|
||||
sql: 'select * from "users"'
|
||||
},
|
||||
});
|
||||
|
||||
testsql(qb().table('users').orderBy('name', 'desc').clearOrder().orderBy('id', 'asc'), {
|
||||
mysql: {
|
||||
sql: 'select * from `users` order by `id` asc'
|
||||
},
|
||||
mssql: {
|
||||
sql: 'select * from [users] order by [id] asc'
|
||||
},
|
||||
postgres: {
|
||||
sql: 'select * from "users" order by "id" asc'
|
||||
},
|
||||
redshift: {
|
||||
sql: 'select * from "users" order by "id" asc'
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("basic wheres", function() {
|
||||
testsql(qb().select('*').from('users').where('id', '=', 1), {
|
||||
mysql: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user