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

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
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**
Added support for `CITEXT` for Postgres and SQLite
......@@ -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
- 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
- removed: terraformer-wkt-parser [#9545](https://github.com/sequelize/sequelize/pull/9545)
- mysql2: use `1.5.2` or above to support prepared statements
- updated: retry-as-promised: `3.1.0`
- change: `generic-pool` to `sequelize-pool`
- removed: `generic-pool`
- added: `sequelize-pool`
## Changelog
......
......@@ -156,11 +156,11 @@ Each `write` or `useMaster: true` query will use write pool. For `SELECT` read p
## 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
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
const sequelize = new Sequelize('database', 'username', 'password', {
......@@ -189,7 +189,7 @@ const sequelize = new Sequelize('mariadb://user:password@example.com:9821/databa
### 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
const sequelize = new Sequelize('database', 'username', 'password', {
......@@ -211,7 +211,7 @@ const sequelize = new Sequelize('sqlite:relativePath/dbname.db')
### 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
const sequelize = new Sequelize('database', 'username', 'password', {
......@@ -235,7 +235,7 @@ const sequelize = new Sequelize('database', 'username', 'password', {
### 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
const sequelize = new Sequelize('database', 'username', 'password', {
......
......@@ -13,7 +13,7 @@ function isModel(model, sequelize) {
}
const Mixin = {
hasMany(target, options = {}) { // testhint options:none
hasMany(target, options = {}) {
if (!isModel(target, this.sequelize)) {
throw new Error(`${this.name}.hasMany called with something that's not a subclass of Sequelize.Model`);
}
......@@ -44,7 +44,7 @@ const Mixin = {
return association;
},
belongsToMany(target, options = {}) { // testhint options:none
belongsToMany(target, options = {}) {
if (!isModel(target, this.sequelize)) {
throw new Error(`${this.name}.belongsToMany called with something that's not a subclass of Sequelize.Model`);
}
......@@ -86,7 +86,7 @@ const Mixin = {
// The logic for hasOne and belongsTo is exactly the same
function singleLinked(Type) {
return function(target, options = {}) { // testhint options:none
return function(target, options = {}) {
if (!isModel(target, this.sequelize)) {
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 {
connect(config) {
const connectionConfig = {
userName: config.username,
password: config.password,
server: config.host,
authentication: {
type: 'default',
options: {
port: config.port,
userName: config.username || undefined,
password: config.password || undefined
}
},
options: {
port: parseInt(config.port, 10),
database: config.database,
encrypt: false
}
......@@ -40,15 +45,18 @@ class ConnectionManager extends AbstractConnectionManager {
if (config.dialectOptions) {
// 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;
}
// The 'tedious' driver needs domain property to be in the main Connection config object
if (config.dialectOptions.domain) {
connectionConfig.domain = config.dialectOptions.domain;
if (config.dialectOptions.authentication) {
Object.assign(connectionConfig.authentication, config.dialectOptions.authentication);
}
Object.assign(connectionConfig.options, config.dialectOptions);
Object.assign(connectionConfig.options, config.dialectOptions.options);
}
return new Promise((resolve, reject) => {
......
......@@ -892,7 +892,7 @@ class Model {
*
* @returns {Model}
*/
static init(attributes, options = {}) { // testhint options:none
static init(attributes, options = {}) {
if (!options.sequelize) {
throw new Error('No Sequelize instance passed');
}
......@@ -1381,7 +1381,7 @@ class Model {
*
* @returns {Model}
*/
static schema(schema, options) { // testhint options:none
static schema(schema, options) {
const clone = class extends this {};
Object.defineProperty(clone, 'name', { value: this.name });
......@@ -1405,7 +1405,7 @@ class Model {
*
* @returns {string|Object}
*/
static getTableName() { // testhint options:none
static getTableName() {
return this.QueryGenerator.addSchema(this);
}
......@@ -2109,7 +2109,7 @@ class Model {
*
* @returns {Model|Array<Model>}
*/
static build(values, options) { // testhint options:none
static build(values, options) {
if (Array.isArray(values)) {
return this.bulkBuild(values, options);
}
......@@ -2117,7 +2117,7 @@ class Model {
return new this(values, options);
}
static bulkBuild(valueSets, options) { // testhint options:none
static bulkBuild(valueSets, options) {
options = Object.assign({
isNewRecord: true
}, options || {});
......@@ -3273,7 +3273,7 @@ class Model {
*
* @returns {Object|any}
*/
get(key, options) { // testhint options:none
get(key, options) {
if (options === undefined && typeof key === 'object') {
options = key;
key = undefined;
......@@ -3360,7 +3360,7 @@ class Model {
*
* @returns {<Model>}
*/
set(key, value, options) { // testhint options:none
set(key, value, options) {
let values;
let originalValue;
......
......@@ -636,7 +636,6 @@ class QueryInterface {
options = attributes;
attributes = options.fields;
}
// testhint argsConform.end
if (!rawTablename) {
// Map for backwards compat
......
......@@ -83,7 +83,7 @@
"sinon": "^7.2.6",
"sinon-chai": "^3.2.0",
"sqlite3": "^4.0.6",
"tedious": "^3.0.1",
"tedious": "^6.0.0",
"typescript": "^3.3.3333"
},
"keywords": [
......
......@@ -5,28 +5,36 @@ 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()
$serverName = $env:COMPUTERNAME
$instanceName = 'SQL2017'
$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer')
$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
# Enable TCP/IP
$uri = "ManagedComputer[@Name='$serverName']/ServerInstance[@Name='$instanceName']/ServerProtocol[@Name='Tcp']"
$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 = @{
instanceName = "SQL2017"
host = "localhost"
username = "sa"
password = "Password12!"
port = $port
database = "sequelize_test"
dialectOptions = @{
options = @{
requestTimeout = 25000
cryptoCredentialsDetails = @{
ciphers = "RC4-MD5"
}
}
}
pool = @{
max = 5
idle = 3000
......
......@@ -30,8 +30,9 @@ module.exports = {
host: env.SEQ_MSSQL_HOST || env.SEQ_HOST || '127.0.0.1',
port: env.SEQ_MSSQL_PORT || env.SEQ_PORT || 1433,
dialectOptions: {
// big insert queries need a while
options: {
requestTimeout: 60000
}
},
pool: {
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'), () => {
.sequelizeWithInvalidConnection
.authenticate()
.catch(err => {
console.log(err);
expect(
err.message.includes('connect ECONNREFUSED') ||
err.message.includes('invalid port number') ||
err.message.match(/should be >=? 0 and < 65536/) ||
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;
});
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!