不要怂,就是干,撸起袖子干!

Commit e5c0d786 by Sushant Committed by GitHub

feat: upgrade to tedious@6.0.0 (#10494)

1 parent e0fe7726
...@@ -78,10 +78,6 @@ Many model based aliases has been removed [#9372](https://github.com/sequelize/s ...@@ -78,10 +78,6 @@ Many model based aliases has been removed [#9372](https://github.com/sequelize/s
Now supports only one standard format `[{ value: 1, inclusive: true }, { value: 20, inclusive: false }]` [#9364](https://github.com/sequelize/sequelize/pull/9364) Now supports only one standard format `[{ value: 1, inclusive: true }, { value: 20, inclusive: false }]` [#9364](https://github.com/sequelize/sequelize/pull/9364)
**Network types**
Added support for `CIDR`, `INET` and `MACADDR` for Postgres
**Case insensitive text** **Case insensitive text**
Added support for `CITEXT` for Postgres and SQLite Added support for `CITEXT` for Postgres and SQLite
...@@ -181,13 +177,39 @@ Model.findAll({ ...@@ -181,13 +177,39 @@ Model.findAll({
- [retry-as-promised](https://github.com/mickhansen/retry-as-promised) has been updated to `3.1.0`, which use [any-promise](https://github.com/kevinbeaty/any-promise). This module repeat all `sequelize.query` operations. You can configure `any-promise` to use `bluebird` for better performance on Node 4 or 6 - [retry-as-promised](https://github.com/mickhansen/retry-as-promised) has been updated to `3.1.0`, which use [any-promise](https://github.com/kevinbeaty/any-promise). This module repeat all `sequelize.query` operations. You can configure `any-promise` to use `bluebird` for better performance on Node 4 or 6
- Sequelize will throw for all `undefined` keys in `where` options, In past versions `undefined` was converted to `null`. - Sequelize will throw for all `undefined` keys in `where` options, In past versions `undefined` was converted to `null`.
### Dialect Specific
#### MSSQL
- Sequelize now works with `tedious@6.0.0`, this means old `dialectOptions` has to be updated to match their new format. Please refer to tedious [documentation](http://tediousjs.github.io/tedious/api-connection.html#function_newConnection). An example of new `dialectOptions` is given below
```json
dialectOptions: {
authentication: {
domain: 'my-domain'
},
options: {
requestTimeout: 60000,
cryptoCredentialsDetails: {
ciphers: "RC4-MD5"
}
}
}
```
#### MySQL
- Requires `mysql2 >= 1.5.2` for prepared statements
#### MariaDB
- `dialect: 'mariadb'` is now [supported](https://github.com/sequelize/sequelize/pull/10192) with `mariadb` package
### Packages ### Packages
- removed: terraformer-wkt-parser [#9545](https://github.com/sequelize/sequelize/pull/9545) - removed: terraformer-wkt-parser [#9545](https://github.com/sequelize/sequelize/pull/9545)
- mysql2: use `1.5.2` or above to support prepared statements - removed: `generic-pool`
- updated: retry-as-promised: `3.1.0` - added: `sequelize-pool`
- change: `generic-pool` to `sequelize-pool`
## Changelog ## Changelog
......
...@@ -156,11 +156,11 @@ Each `write` or `useMaster: true` query will use write pool. For `SELECT` read p ...@@ -156,11 +156,11 @@ Each `write` or `useMaster: true` query will use write pool. For `SELECT` read p
## Dialects ## Dialects
With the release of Sequelize `1.6.0`, the library got independent from specific dialects. This means, that you'll have to add the respective connector library to your project yourself. With the release of Sequelize `1.6.0`, the library got independent from specific dialects. This means, that you'll have to install the respective connector library to your project yourself.
### MySQL ### MySQL
In order to get Sequelize working nicely together with MySQL, you'll need to install`mysql2@^1.0.0-rc.10`or higher. Once that's done you can use it like this: In order to get Sequelize working nicely together with MySQL, you'll need to install`mysql2@^1.5.2`or higher. Once that's done you can use it like this:
```js ```js
const sequelize = new Sequelize('database', 'username', 'password', { const sequelize = new Sequelize('database', 'username', 'password', {
...@@ -189,7 +189,7 @@ const sequelize = new Sequelize('mariadb://user:password@example.com:9821/databa ...@@ -189,7 +189,7 @@ const sequelize = new Sequelize('mariadb://user:password@example.com:9821/databa
### SQLite ### SQLite
For SQLite compatibility you'll need`sqlite3@~3.0.0`. Configure Sequelize like this: For SQLite compatibility you'll need`sqlite3@^4.0.0`. Configure Sequelize like this:
```js ```js
const sequelize = new Sequelize('database', 'username', 'password', { const sequelize = new Sequelize('database', 'username', 'password', {
...@@ -211,7 +211,7 @@ const sequelize = new Sequelize('sqlite:relativePath/dbname.db') ...@@ -211,7 +211,7 @@ const sequelize = new Sequelize('sqlite:relativePath/dbname.db')
### PostgreSQL ### PostgreSQL
The library for PostgreSQL is`pg@^5.0.0 || ^6.0.0` You'll just need to define the dialect: The library for PostgreSQL is`pg@^7.0.0` You'll just need to define the dialect:
```js ```js
const sequelize = new Sequelize('database', 'username', 'password', { const sequelize = new Sequelize('database', 'username', 'password', {
...@@ -235,7 +235,7 @@ const sequelize = new Sequelize('database', 'username', 'password', { ...@@ -235,7 +235,7 @@ const sequelize = new Sequelize('database', 'username', 'password', {
### MSSQL ### MSSQL
The library for MSSQL is`tedious@^3.0.0` You'll just need to define the dialect: The library for MSSQL is`tedious@^6.0.0` You'll just need to define the dialect:
```js ```js
const sequelize = new Sequelize('database', 'username', 'password', { const sequelize = new Sequelize('database', 'username', 'password', {
......
...@@ -13,7 +13,7 @@ function isModel(model, sequelize) { ...@@ -13,7 +13,7 @@ function isModel(model, sequelize) {
} }
const Mixin = { const Mixin = {
hasMany(target, options = {}) { // testhint options:none hasMany(target, options = {}) {
if (!isModel(target, this.sequelize)) { if (!isModel(target, this.sequelize)) {
throw new Error(`${this.name}.hasMany called with something that's not a subclass of Sequelize.Model`); throw new Error(`${this.name}.hasMany called with something that's not a subclass of Sequelize.Model`);
} }
...@@ -44,7 +44,7 @@ const Mixin = { ...@@ -44,7 +44,7 @@ const Mixin = {
return association; return association;
}, },
belongsToMany(target, options = {}) { // testhint options:none belongsToMany(target, options = {}) {
if (!isModel(target, this.sequelize)) { if (!isModel(target, this.sequelize)) {
throw new Error(`${this.name}.belongsToMany called with something that's not a subclass of Sequelize.Model`); throw new Error(`${this.name}.belongsToMany called with something that's not a subclass of Sequelize.Model`);
} }
...@@ -86,7 +86,7 @@ const Mixin = { ...@@ -86,7 +86,7 @@ const Mixin = {
// The logic for hasOne and belongsTo is exactly the same // The logic for hasOne and belongsTo is exactly the same
function singleLinked(Type) { function singleLinked(Type) {
return function(target, options = {}) { // testhint options:none return function(target, options = {}) {
if (!isModel(target, this.sequelize)) { if (!isModel(target, this.sequelize)) {
throw new Error(`${this.name}.${_.lowerFirst(Type.name)} called with something that's not a subclass of Sequelize.Model`); throw new Error(`${this.name}.${_.lowerFirst(Type.name)} called with something that's not a subclass of Sequelize.Model`);
} }
......
...@@ -28,11 +28,16 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -28,11 +28,16 @@ class ConnectionManager extends AbstractConnectionManager {
connect(config) { connect(config) {
const connectionConfig = { const connectionConfig = {
userName: config.username,
password: config.password,
server: config.host, server: config.host,
authentication: {
type: 'default',
options: { options: {
port: config.port, userName: config.username || undefined,
password: config.password || undefined
}
},
options: {
port: parseInt(config.port, 10),
database: config.database, database: config.database,
encrypt: false encrypt: false
} }
...@@ -40,15 +45,18 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -40,15 +45,18 @@ class ConnectionManager extends AbstractConnectionManager {
if (config.dialectOptions) { if (config.dialectOptions) {
// only set port if no instance name was provided // only set port if no instance name was provided
if (config.dialectOptions.instanceName) { if (
config.dialectOptions.options &&
config.dialectOptions.options.instanceName
) {
delete connectionConfig.options.port; delete connectionConfig.options.port;
} }
// The 'tedious' driver needs domain property to be in the main Connection config object if (config.dialectOptions.authentication) {
if (config.dialectOptions.domain) { Object.assign(connectionConfig.authentication, config.dialectOptions.authentication);
connectionConfig.domain = config.dialectOptions.domain;
} }
Object.assign(connectionConfig.options, config.dialectOptions);
Object.assign(connectionConfig.options, config.dialectOptions.options);
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
......
...@@ -892,7 +892,7 @@ class Model { ...@@ -892,7 +892,7 @@ class Model {
* *
* @returns {Model} * @returns {Model}
*/ */
static init(attributes, options = {}) { // testhint options:none static init(attributes, options = {}) {
if (!options.sequelize) { if (!options.sequelize) {
throw new Error('No Sequelize instance passed'); throw new Error('No Sequelize instance passed');
} }
...@@ -1381,7 +1381,7 @@ class Model { ...@@ -1381,7 +1381,7 @@ class Model {
* *
* @returns {Model} * @returns {Model}
*/ */
static schema(schema, options) { // testhint options:none static schema(schema, options) {
const clone = class extends this {}; const clone = class extends this {};
Object.defineProperty(clone, 'name', { value: this.name }); Object.defineProperty(clone, 'name', { value: this.name });
...@@ -1405,7 +1405,7 @@ class Model { ...@@ -1405,7 +1405,7 @@ class Model {
* *
* @returns {string|Object} * @returns {string|Object}
*/ */
static getTableName() { // testhint options:none static getTableName() {
return this.QueryGenerator.addSchema(this); return this.QueryGenerator.addSchema(this);
} }
...@@ -2109,7 +2109,7 @@ class Model { ...@@ -2109,7 +2109,7 @@ class Model {
* *
* @returns {Model|Array<Model>} * @returns {Model|Array<Model>}
*/ */
static build(values, options) { // testhint options:none static build(values, options) {
if (Array.isArray(values)) { if (Array.isArray(values)) {
return this.bulkBuild(values, options); return this.bulkBuild(values, options);
} }
...@@ -2117,7 +2117,7 @@ class Model { ...@@ -2117,7 +2117,7 @@ class Model {
return new this(values, options); return new this(values, options);
} }
static bulkBuild(valueSets, options) { // testhint options:none static bulkBuild(valueSets, options) {
options = Object.assign({ options = Object.assign({
isNewRecord: true isNewRecord: true
}, options || {}); }, options || {});
...@@ -3273,7 +3273,7 @@ class Model { ...@@ -3273,7 +3273,7 @@ class Model {
* *
* @returns {Object|any} * @returns {Object|any}
*/ */
get(key, options) { // testhint options:none get(key, options) {
if (options === undefined && typeof key === 'object') { if (options === undefined && typeof key === 'object') {
options = key; options = key;
key = undefined; key = undefined;
...@@ -3360,7 +3360,7 @@ class Model { ...@@ -3360,7 +3360,7 @@ class Model {
* *
* @returns {<Model>} * @returns {<Model>}
*/ */
set(key, value, options) { // testhint options:none set(key, value, options) {
let values; let values;
let originalValue; let originalValue;
......
...@@ -636,7 +636,6 @@ class QueryInterface { ...@@ -636,7 +636,6 @@ class QueryInterface {
options = attributes; options = attributes;
attributes = options.fields; attributes = options.fields;
} }
// testhint argsConform.end
if (!rawTablename) { if (!rawTablename) {
// Map for backwards compat // Map for backwards compat
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
"sinon": "^7.2.6", "sinon": "^7.2.6",
"sinon-chai": "^3.2.0", "sinon-chai": "^3.2.0",
"sqlite3": "^4.0.6", "sqlite3": "^4.0.6",
"tedious": "^3.0.1", "tedious": "^6.0.0",
"typescript": "^3.3.3333" "typescript": "^3.3.3333"
}, },
"keywords": [ "keywords": [
......
...@@ -5,28 +5,36 @@ Start-Service sqlbrowser ...@@ -5,28 +5,36 @@ Start-Service sqlbrowser
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | Out-Null [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | Out-Null
$wmi = New-Object('Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer') $serverName = $env:COMPUTERNAME
$tcp = $wmi.GetSmoObject("ManagedComputer[@Name='${env:computername}']/ServerInstance[@Name='SQL2017']/ServerProtocol[@Name='Tcp']") $instanceName = 'SQL2017'
$tcp.IsEnabled = $true $smo = 'Microsoft.SqlServer.Management.Smo.'
$tcp.Alter() $wmi = new-object ($smo + 'Wmi.ManagedComputer')
$wmi = New-Object('Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer') # Enable TCP/IP
$ipall = $wmi.GetSmoObject("ManagedComputer[@Name='${env:computername}']/ServerInstance[@Name='SQL2017']/ServerProtocol[@Name='Tcp']/IPAddress[@Name='IPAll']") $uri = "ManagedComputer[@Name='$serverName']/ServerInstance[@Name='$instanceName']/ServerProtocol[@Name='Tcp']"
$port = $ipall.IPAddressProperties.Item("TcpDynamicPorts").Value $Tcp = $wmi.GetSmoObject($uri)
$Tcp.IsEnabled = $true
$TCP.alter()
Start-Service "MSSQL`$$instanceName"
$ipall = $wmi.GetSmoObject("ManagedComputer[@Name='$serverName']/ServerInstance[@Name='$instanceName']/ServerProtocol[@Name='Tcp']/IPAddress[@Name='IPAll']")
$port = $ipall.IPAddressProperties.Item("TcpPort").Value
$config = @{ $config = @{
instanceName = "SQL2017"
host = "localhost" host = "localhost"
username = "sa" username = "sa"
password = "Password12!" password = "Password12!"
port = $port port = $port
database = "sequelize_test" database = "sequelize_test"
dialectOptions = @{ dialectOptions = @{
options = @{
requestTimeout = 25000 requestTimeout = 25000
cryptoCredentialsDetails = @{ cryptoCredentialsDetails = @{
ciphers = "RC4-MD5" ciphers = "RC4-MD5"
} }
} }
}
pool = @{ pool = @{
max = 5 max = 5
idle = 3000 idle = 3000
......
...@@ -30,8 +30,9 @@ module.exports = { ...@@ -30,8 +30,9 @@ module.exports = {
host: env.SEQ_MSSQL_HOST || env.SEQ_HOST || '127.0.0.1', host: env.SEQ_MSSQL_HOST || env.SEQ_HOST || '127.0.0.1',
port: env.SEQ_MSSQL_PORT || env.SEQ_PORT || 1433, port: env.SEQ_MSSQL_PORT || env.SEQ_PORT || 1433,
dialectOptions: { dialectOptions: {
// big insert queries need a while options: {
requestTimeout: 60000 requestTimeout: 60000
}
}, },
pool: { pool: {
max: env.SEQ_MSSQL_POOL_MAX || env.SEQ_POOL_MAX || 5, max: env.SEQ_MSSQL_POOL_MAX || env.SEQ_POOL_MAX || 5,
......
'use strict';
const path = require('path');
module.exports = {
configFile: path.resolve('config', 'database.json'),
migrationsPath: path.resolve('db', 'migrate')
};
...@@ -121,12 +121,13 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { ...@@ -121,12 +121,13 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
.sequelizeWithInvalidConnection .sequelizeWithInvalidConnection
.authenticate() .authenticate()
.catch(err => { .catch(err => {
console.log(err);
expect( expect(
err.message.includes('connect ECONNREFUSED') || err.message.includes('connect ECONNREFUSED') ||
err.message.includes('invalid port number') || err.message.includes('invalid port number') ||
err.message.match(/should be >=? 0 and < 65536/) || err.message.match(/should be >=? 0 and < 65536/) ||
err.message.includes('Login failed for user') || err.message.includes('Login failed for user') ||
err.message.includes('Port must be > 0 and < 65536') err.message.includes('must be > 0 and < 65536')
).to.be.ok; ).to.be.ok;
}); });
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!