Skip to content

Commit

Permalink
support most recent knex
Browse files Browse the repository at this point in the history
  • Loading branch information
koskimas committed May 23, 2020
1 parent 926bf3e commit 3c42d76
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
6 changes: 6 additions & 0 deletions doc/release-notes/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.1.4

### What's new

- Fixes [#1750](https://github.com/Vincit/objection.js/issues/1750)

## 2.1.3

### What's new
Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ services:
postgres:
image: 'postgres'
container_name: 'objection_postgres'
command: postgres -c fsync=off -c synchronous_commit=off -c full_page_writes=off -c random_page_cost=1.0
command: postgres -c fsync=off -c synchronous_commit=off -c full_page_writes=off -c random_page_cost=1.0
ports:
- '5432:5432'
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
mysql:
image: 'mysql:5'
container_name: 'objection_mysql'
ports:
- '3306:3306'
environment:
- 'MYSQL_ALLOW_EMPTY_PASSWORD=yes'
- 'MYSQL_ALLOW_EMPTY_PASSWORD=yes'
4 changes: 4 additions & 0 deletions lib/queryBuilder/QueryBuilderBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ class QueryBuilderBase extends QueryBuilderOperationSupport {
return this.addOperation(new KnexOperation('clearHaving'), args);
}

clearGroup(...args) {
return this.addOperation(new KnexOperation('clearGroup'), args);
}

orHaving(...args) {
return this.addOperation(new KnexOperation('orHaving'), args);
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "objection",
"version": "2.1.3",
"version": "2.1.4",
"description": "An SQL-friendly ORM for Node.js",
"main": "lib/objection.js",
"license": "MIT",
Expand Down Expand Up @@ -79,7 +79,7 @@
"fs-extra": "^8.1.0",
"glob": "^7.1.6",
"husky": "^3.1.0",
"knex": "0.20.11",
"knex": "0.21.1",
"lint-staged": "^9.4.3",
"mocha": "^6.2.2",
"mysql": "^2.18.1",
Expand Down
8 changes: 4 additions & 4 deletions testUtils/mockKnex.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const _ = require('lodash');
const knexMethods = require('knex/lib/query/methods').concat('queryBuilder');
const knexMethods = require('knex/lib/query/methods').concat('queryBuilder', 'raw');

/**
* @param {function} knex
Expand All @@ -12,15 +12,15 @@ const knexMethods = require('knex/lib/query/methods').concat('queryBuilder');
* Mocked knex.
*/
module.exports = function mockKnex(knex, mockExecutor) {
const mock = (table) => {
const mock = table => {
return mock.queryBuilder().table(table);
};

// Mock query builder methods.
knexMethods.forEach(methodName => {
mock[methodName] = (...args) => {
return wrapBuilder(knex[methodName](...args));
}
};
});

const keys = _.uniqBy([...Object.keys(knex), 'client']);
Expand Down Expand Up @@ -55,7 +55,7 @@ module.exports = function mockKnex(knex, mockExecutor) {
function wrapBuilder(builder) {
const oldImpl = builder.then;

builder.then = function (...args) {
builder.then = function(...args) {
return mockExecutor.call(this, mock, oldImpl, args);
};

Expand Down

0 comments on commit 3c42d76

Please sign in to comment.