From 4feefdf3d2532c23f2f662c538bf2d81700daeb1 Mon Sep 17 00:00:00 2001 From: Igor Savin Date: Sun, 29 Dec 2019 20:28:40 +0100 Subject: [PATCH] Enforce Unix (lf) line terminators (#3598) --- .prettierrc | 5 +- CHANGELOG.md | 6 ++ lib/client.js | 2 +- lib/dialects/postgres/query/compiler.js | 2 +- lib/query/builder.js | 2 +- lib/schema/tablebuilder.js | 6 +- package.json | 2 +- test/integration/builder/selects.js | 73 +++++++++++++------------ test/unit/schema/mssql.js | 15 +++-- 9 files changed, 63 insertions(+), 50 deletions(-) diff --git a/.prettierrc b/.prettierrc index b524caffe8..19688250ad 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,6 @@ { "singleQuote": true, "trailingComma": "es5", - "arrowParens": "always" -} \ No newline at end of file + "arrowParens": "always", + "endOfLine": "lf" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cadce91d5..d83cf17f1d 100644 --- a/CHANGELOG.md +++ b/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: diff --git a/lib/client.js b/lib/client.js index c0aee7d0f6..15c4de27d1 100644 --- a/lib/client.js +++ b/lib/client.js @@ -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'); diff --git a/lib/dialects/postgres/query/compiler.js b/lib/dialects/postgres/query/compiler.js index 62541fd2af..6fee2f88dc 100644 --- a/lib/dialects/postgres/query/compiler.js +++ b/lib/dialects/postgres/query/compiler.js @@ -160,7 +160,7 @@ Object.assign(QueryCompiler_PG.prototype, { distinctOn(value) { return 'distinct on (' + this.formatter.columnize(value) + ') '; - } + }, }); module.exports = QueryCompiler_PG; diff --git a/lib/query/builder.js b/lib/query/builder.js index 5ac69818c2..1ba330c920 100644 --- a/lib/query/builder.js +++ b/lib/query/builder.js @@ -201,7 +201,7 @@ assign(Builder.prototype, { this._statements.push({ grouping: 'columns', value, - distinctOn: true + distinctOn: true, }); return this; }, diff --git a/lib/schema/tablebuilder.js b/lib/schema/tablebuilder.js index 34f3d50cbd..be54eb78d9 100644 --- a/lib/schema/tablebuilder.js +++ b/lib/schema/tablebuilder.js @@ -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; diff --git a/package.json b/package.json index d960344d62..97d7634d10 100644 --- a/package.json +++ b/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", diff --git a/test/integration/builder/selects.js b/test/integration/builder/selects.js index 8297ac5079..63f840b116 100644 --- a/test/integration/builder/selects.js +++ b/test/integration/builder/selects.js @@ -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() { diff --git a/test/unit/schema/mssql.js b/test/unit/schema/mssql.js index b352b0c8fd..78652c74d2 100644 --- a/test/unit/schema/mssql.js +++ b/test/unit/schema/mssql.js @@ -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'); });