Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test/support
src/assets
11 changes: 6 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"no-console": "off",
"no-extra-parens": "warn",
"valid-jsdoc": "off",
"new-cap": ["warn", {"properties": false}],
"comma-spacing": ["error", {"before": false, "after": true}],
"new-cap": ["warn", { "properties": false }],
"comma-spacing": ["error", { "before": false, "after": true }],
"no-extra-boolean-cast": "warn",
"strict": ["warn", "global"],
"no-var": "error",
Expand All @@ -21,14 +21,14 @@
"eqeqeq": "error",
"no-extend-native": "error",
"wrap-iife": ["error", "any"],
"indent": ["error", 2, {"SwitchCase": 1}],
"indent": ["error", 2, { "SwitchCase": 1 }],
"no-use-before-define": "off",
"no-caller": "error",
"no-undef": "error",
"no-unused-vars": "error",
"no-irregular-whitespace": "error",
"max-depth": ["error", 8],
"quotes": ["error", "single", {"avoidEscape": true}],
"quotes": ["error", "single", { "avoidEscape": true }],
"linebreak-style": "error",
"no-loop-func": "warn",
"object-shorthand": "error",
Expand All @@ -45,5 +45,6 @@
"node": true,
"mocha": true,
"es6": true
}
},
"root": true
}
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ cache:

jobs:
include:
- stage: tests
node_js: 4
env: DIALECT=postgres SEQUELIZE=latest
- stage: tests
node_js: 4
env: DIALECT=sqlite SEQUELIZE=latest

Expand Down
42 changes: 42 additions & 0 deletions appveyor-setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

Set-Service sqlbrowser -StartupType auto
Start-Service sqlbrowser

[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | Out-Null

$wmi = New-Object('Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer')
$tcp = $wmi.GetSmoObject("ManagedComputer[@Name='${env:computername}']/ServerInstance[@Name='SQL2017']/ServerProtocol[@Name='Tcp']")
$tcp.IsEnabled = $true
$tcp.Alter()

$wmi = New-Object('Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer')
$ipall = $wmi.GetSmoObject("ManagedComputer[@Name='${env:computername}']/ServerInstance[@Name='SQL2017']/ServerProtocol[@Name='Tcp']/IPAddress[@Name='IPAll']")
$port = $ipall.IPAddressProperties.Item("TcpDynamicPorts").Value

$config = @{
instanceName = "SQL2017"
host = "localhost"
username = "sa"
password = "Password12!"
port = $port
database = "sequelize_test"
dialectOptions = @{
requestTimeout = 25000
cryptoCredentialsDetails = @{
ciphers = "RC4-MD5"
}
}
pool = @{
max = 5
idle = 3000
}
}

$json = $config | ConvertTo-Json -Depth 3

# Create sequelize_test database
sqlcmd -S "(local)" -U "sa" -P "Password12!" -d "master" -Q "CREATE DATABASE [sequelize_test]; ALTER DATABASE [sequelize_test] SET READ_COMMITTED_SNAPSHOT ON;"

# cannot use Out-File because it outputs a BOM
[IO.File]::WriteAllLines((Join-Path $pwd "test\support\config\mssql.json"), $json)
33 changes: 33 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '{build}'

platform:
- x64

services:
- mssql2017

shallow_clone: true

build: off

matrix:
fast_finish: true

environment:
matrix:
- { NODE_VERSION: 6, DIALECT: mssql }

install:
- ps: Install-Product node $env:NODE_VERSION x64
- "set PATH=%APPVEYOR_BUILD_FOLDER%\\lib;%PATH%"
- ps: |
$pkg = ConvertFrom-Json (Get-Content -Raw package.json)
$pkg.devDependencies.PSObject.Properties.Remove('sqlite3')
ConvertTo-Json $pkg | Out-File package.json -Encoding UTF8
- npm install

before_test:
- ps: . .\appveyor-setup.ps1

test_script:
- 'npm run test'
31 changes: 14 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,40 @@
"cli-color": "^1.2.0",
"fs-extra": "^5.0.0",
"js-beautify": "^1.7.4",
"lodash": "^4.17.5",
"resolve": "^1.5.0",
"lodash": "^4.17.10",
"resolve": "^1.7.1",
"umzug": "^2.1.0",
"yargs": "^8.0.2"
},
"peerDependencies": {
"sequelize": "=3 || =4 || =5"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-plugin-transform-async-to-module-method": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-env": "^1.7.0",
"babel-register": "^6.24.1",
"eslint": "^4.11.0",
"eslint": "^4.19.1",
"expect.js": "^0.3.1",
"gulp": "^3.9.1",
"mocha": "^3.5.0",
"mysql": "^2.15.0",
"nodeify": "^1.0.1",
"pg": "^7.*",
"pg": "^7.4.3",
"pg-hstore": "^2.x",
"sequelize": "^4.x",
"sqlite3": "^3.x",
"sequelize": "^4.37.10",
"sqlite3": "^4.0.0",
"tedious": "^2.6.1",
"through2": "^2.0.3"
},
"options": {
"mocha": "--require scripts/mocha-bootload.js --check-leaks --timeout 30000 --colors --reporter spec"
},
"eslintIgnore": [
"test/support",
"src/assets"
],
"scripts": {
"build": "npm run build-clean && babel src -d lib && npm run build-bin && npm run build-assets",
"build-bin": "mv ./lib/sequelize.js ./lib/sequelize && chmod +x ./lib/sequelize",
"build-bin": "cp ./lib/sequelize.js ./lib/sequelize && chmod +x ./lib/sequelize ./lib/sequelize.js",
"build-assets": "cp -R ./src/assets ./lib/",
"build-clean": "rm -rf ./lib/",
"lint": "eslint test src",
"test-raw": "mocha $npm_package_options_mocha 'test/**/*.test.js'",
"lint": "eslint test src --quiet",
"test-raw": "mocha --require scripts/mocha-bootload.js --check-leaks --timeout 30000 --colors --reporter spec test/**/*.test.js",
"test": "npm run lint && npm run build && npm run test-raw"
},
"repository": {
Expand Down
1 change: 1 addition & 0 deletions src/core/migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export function ensureCurrentMetaSchema (migrator) {
function ensureMetaTable (queryInterface, tableName) {
return queryInterface.showAllTables()
.then(tableNames => {
tableNames = tableNames.map(tableName => tableName.tableName || tableName); // MSSQL
if (tableNames.indexOf(tableName) === -1) {
throw new Error('No MetaTable table found.');
}
Expand Down
12 changes: 10 additions & 2 deletions test/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ const gulp = require('gulp');

describe('models/index.js', () => {
it('correctly injects the reference to the default config file', done => {
const path = Support.isWindows()
? '__dirname + \'/..\\config\\config.json\''
: '__dirname + \'/../config/config.json\'';

gulp
.src(Support.resolveSupportPath('tmp'))
.pipe(helpers.clearDirectory())
Expand All @@ -94,12 +98,16 @@ const gulp = require('gulp');
gulp
.src(Support.resolveSupportPath('tmp', 'models'))
.pipe(helpers.readFile('index.js'))
.pipe(helpers.ensureContent('__dirname + \'/../config/config.json\''))
.pipe(helpers.ensureContent(path))
.pipe(helpers.teardown(done));
}));
});

it('correctly injects the reference to the custom config file', done => {
const path = Support.isWindows()
? '__dirname + \'/..\\my\\configuration-file.json\''
: '__dirname + \'/../my/configuration-file.json\'';

gulp
.src(Support.resolveSupportPath('tmp'))
.pipe(helpers.clearDirectory())
Expand All @@ -108,7 +116,7 @@ const gulp = require('gulp');
gulp
.src(Support.resolveSupportPath('tmp', 'models'))
.pipe(helpers.readFile('index.js'))
.pipe(helpers.ensureContent('__dirname + \'/../my/configuration-file.json\''))
.pipe(helpers.ensureContent(path))
.pipe(helpers.teardown(done));
}));
});
Expand Down
48 changes: 30 additions & 18 deletions test/support/config/config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
'use strict';

const fs = require('fs');
let mssqlConfig;
try {
mssqlConfig = JSON.parse(fs.readFileSync(__dirname + '/mssql.json', 'utf8'));
} catch (e) {
// ignore
}

module.exports = {
username: process.env.SEQ_USER || 'root',
password: process.env.SEQ_PW || null,
database: process.env.SEQ_DB || 'sequelize_test',
host: process.env.SEQ_HOST || '127.0.0.1',
pool: {
maxConnections: process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_POOL_IDLE || 30000
max: process.env.SEQ_POOL_MAX || 5,
idle: process.env.SEQ_POOL_IDLE || 30000
},

rand: function () {
Expand All @@ -22,8 +30,24 @@ module.exports = {
host: process.env.SEQ_MYSQL_HOST || process.env.SEQ_HOST || '127.0.0.1',
port: process.env.SEQ_MYSQL_PORT || process.env.SEQ_PORT || 3306,
pool: {
maxConnections: process.env.SEQ_MYSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_MYSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
max: process.env.SEQ_MYSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
idle: process.env.SEQ_MYSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
}
},

mssql: mssqlConfig || {
database: process.env.SEQ_MSSQL_DB || process.env.SEQ_DB || 'sequelize_test',
username: process.env.SEQ_MSSQL_USER || process.env.SEQ_USER || 'sequelize',
password: process.env.SEQ_MSSQL_PW || process.env.SEQ_PW || 'nEGkLma26gXVHFUAHJxcmsrK',
host: process.env.SEQ_MSSQL_HOST || process.env.SEQ_HOST || '127.0.0.1',
port: process.env.SEQ_MSSQL_PORT || process.env.SEQ_PORT || 1433,
dialectOptions: {
// big insert queries need a while
requestTimeout: 60000
},
pool: {
max: process.env.SEQ_MSSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
idle: process.env.SEQ_MSSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
}
},

Expand All @@ -37,20 +61,8 @@ module.exports = {
host: process.env.SEQ_PG_HOST || process.env.SEQ_HOST || '127.0.0.1',
port: process.env.SEQ_PG_PORT || process.env.SEQ_PORT || 5432,
pool: {
maxConnections: process.env.SEQ_PG_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_PG_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
}
},

mariadb: {
database: process.env.SEQ_MYSQL_DB || process.env.SEQ_DB || 'sequelize_test',
username: process.env.SEQ_MYSQL_USER || process.env.SEQ_USER || 'root',
password: process.env.SEQ_MYSQL_PW || process.env.SEQ_PW || null,
host: process.env.SEQ_MYSQL_HOST || process.env.SEQ_HOST || '127.0.0.1',
port: process.env.SEQ_MYSQL_PORT || process.env.SEQ_PORT || 3306,
pool: {
maxConnections: process.env.SEQ_MYSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_MYSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
max: process.env.SEQ_PG_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
idle: process.env.SEQ_PG_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
}
}
};
2 changes: 1 addition & 1 deletion test/support/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ module.exports = {
.getQueryInterface()
.showAllTables()
.then(function (tables) {
return callback(tables.sort());
return callback(tables.map(tableName => tableName.tableName || tableName).sort());
});
},

Expand Down
12 changes: 11 additions & 1 deletion test/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,17 @@ var Support = {
},

getCliCommand: function (cwd, flags) {
return this.getCliPath(cwd) + ' ' + flags;
var command = this.getCliPath(cwd) + ' ' + flags;

if (this.isWindows()) {
return `node ${command}`;
}

return command;
},

isWindows() {
return process.platform.startsWith('win');
},

getSupportDirectoryPath: function () {
Expand Down