Skip to content

Commit

Permalink
Enforce Unix (lf) line terminators (#3598)
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Savin committed Dec 29, 2019
1 parent a2a6660 commit 4feefdf
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 50 deletions.
5 changes: 3 additions & 2 deletions .prettierrc
@@ -1,5 +1,6 @@
{
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "always"
}
"arrowParens": "always",
"endOfLine": "lf"
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
# Master (Unreleased)

# 0.20.6 - 29 December, 2019

### Bug fixes:

- Enforce Unix (lf) line terminators #3598

# 0.20.5 - 29 December, 2019

### New features:
Expand Down
2 changes: 1 addition & 1 deletion lib/client.js
Expand Up @@ -30,7 +30,7 @@ const debug = require('debug')('knex:client');
const _debugQuery = require('debug')('knex:query');
const debugBindings = require('debug')('knex:bindings');

const debugQuery = (sql, txId) => _debugQuery(sql.replace(/%/g, '%%'), txId)
const debugQuery = (sql, txId) => _debugQuery(sql.replace(/%/g, '%%'), txId);

const { POOL_CONFIG_OPTIONS } = require('./constants');

Expand Down
2 changes: 1 addition & 1 deletion lib/dialects/postgres/query/compiler.js
Expand Up @@ -160,7 +160,7 @@ Object.assign(QueryCompiler_PG.prototype, {

distinctOn(value) {
return 'distinct on (' + this.formatter.columnize(value) + ') ';
}
},
});

module.exports = QueryCompiler_PG;
2 changes: 1 addition & 1 deletion lib/query/builder.js
Expand Up @@ -201,7 +201,7 @@ assign(Builder.prototype, {
this._statements.push({
grouping: 'columns',
value,
distinctOn: true
distinctOn: true,
});
return this;
},
Expand Down
6 changes: 4 additions & 2 deletions lib/schema/tablebuilder.js
Expand Up @@ -77,12 +77,14 @@ each(specialMethods, function(methods, dialect) {
each(methods, function(method) {
TableBuilder.prototype[method] = function(value) {
if (this.client.dialect !== dialect) {
throw new Error(`Knex only supports ${method} statement with ${dialect}.`);
throw new Error(
`Knex only supports ${method} statement with ${dialect}.`
);
}
if (this._method === 'alter') {
throw new Error(
`Knex does not support altering the ${method} outside of create ` +
`table, please use knex.raw statement.`
`table, please use knex.raw statement.`
);
}
this._single[method] = value;
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "knex",
"version": "0.20.5",
"version": "0.20.6",
"description": "A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser",
"main": "knex.js",
"types": "types/index.d.ts",
Expand Down
73 changes: 37 additions & 36 deletions test/integration/builder/selects.js
Expand Up @@ -794,43 +794,44 @@ module.exports = function(knex) {
} catch (e) {
error = e;
}
expect(error.message).to.eql('.distinctOn() is currently only supported on PostgreSQL');
expect(error.message).to.eql(
'.distinctOn() is currently only supported on PostgreSQL'
);
return;
}
return builder
.testSql(function(tester) {
tester(
'pg',
'select distinct on ("id") "email", "logins" from "accounts" order by "id" asc',
[],
[
{
email: 'test@example.com',
logins: 1,
},
{
email: 'test2@example.com',
logins: 1,
},
{
email: 'test3@example.com',
logins: 2,
},
{
email: 'test4@example.com',
logins: 2,
},
{
email: 'test5@example.com',
logins: 2,
},
{
email: 'test6@example.com',
logins: 2,
},
]
);
});
}
return builder.testSql(function(tester) {
tester(
'pg',
'select distinct on ("id") "email", "logins" from "accounts" order by "id" asc',
[],
[
{
email: 'test@example.com',
logins: 1,
},
{
email: 'test2@example.com',
logins: 1,
},
{
email: 'test3@example.com',
logins: 2,
},
{
email: 'test4@example.com',
logins: 2,
},
{
email: 'test5@example.com',
logins: 2,
},
{
email: 'test6@example.com',
logins: 2,
},
]
);
});
});

it('does "orWhere" cases', function() {
Expand Down
15 changes: 9 additions & 6 deletions test/unit/schema/mssql.js
Expand Up @@ -11,12 +11,15 @@ describe('MSSQL SchemaBuilder', function() {

it('throws when charset and collate are specified', function() {
expect(() => {
tableSql = client.schemaBuilder().createTable('users', function(table) {
table.increments('id');
table.string('email');
table.charset('utf8');
table.collate('utf8_unicode_ci');
}).toSQL();
tableSql = client
.schemaBuilder()
.createTable('users', function(table) {
table.increments('id');
table.string('email');
table.charset('utf8');
table.collate('utf8_unicode_ci');
})
.toSQL();
}).to.throw('Knex only supports charset statement with mysql');
});

Expand Down

0 comments on commit 4feefdf

Please sign in to comment.