Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 8e4f4a94
authored
Mar 23, 2019
by
Simon Schick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: replace lodash clone with spread
1 parent
edd69197
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
56 additions
and
61 deletions
.eslintrc.json
lib/associations/belongs-to-many.js
lib/associations/has-many.js
lib/dialects/postgres/query-interface.js
lib/dialects/sqlite/query-interface.js
lib/instance-validator.js
lib/model.js
lib/query-interface.js
lib/sequelize.js
lib/utils.js
test/integration/dialects/abstract/connection-manager.test.js
test/unit/model/destroy.test.js
test/unit/model/update.test.js
test/unit/sql/create-table.test.js
.eslintrc.json
View file @
8e4f4a9
...
@@ -113,7 +113,7 @@
...
@@ -113,7 +113,7 @@
"no-case-declarations"
:
"off"
"no-case-declarations"
:
"off"
},
},
"parserOptions"
:
{
"parserOptions"
:
{
"ecmaVersion"
:
6
,
"ecmaVersion"
:
9
,
"sourceType"
:
"script"
"sourceType"
:
"script"
},
},
"plugins"
:
[
"plugins"
:
[
...
...
lib/associations/belongs-to-many.js
View file @
8e4f4a9
...
@@ -381,7 +381,7 @@ class BelongsToMany extends Association {
...
@@ -381,7 +381,7 @@ class BelongsToMany extends Association {
let
throughWhere
;
let
throughWhere
;
if
(
this
.
scope
)
{
if
(
this
.
scope
)
{
scopeWhere
=
_
.
clone
(
this
.
scope
)
;
scopeWhere
=
{
...
this
.
scope
}
;
}
}
options
.
where
=
{
options
.
where
=
{
...
@@ -623,7 +623,7 @@ class BelongsToMany extends Association {
...
@@ -623,7 +623,7 @@ class BelongsToMany extends Association {
// If newInstances is null or undefined, no-op
// If newInstances is null or undefined, no-op
if
(
!
newInstances
)
return
Utils
.
Promise
.
resolve
();
if
(
!
newInstances
)
return
Utils
.
Promise
.
resolve
();
options
=
_
.
clone
(
options
)
||
{
};
options
=
{
...
options
};
const
association
=
this
;
const
association
=
this
;
const
sourceKey
=
association
.
source
.
primaryKeyAttribute
;
const
sourceKey
=
association
.
source
.
primaryKeyAttribute
;
...
...
lib/associations/has-many.js
View file @
8e4f4a9
...
@@ -114,7 +114,7 @@ class HasMany extends Association {
...
@@ -114,7 +114,7 @@ class HasMany extends Association {
_injectAttributes
()
{
_injectAttributes
()
{
const
newAttributes
=
{};
const
newAttributes
=
{};
// Create a new options object for use with addForeignKeyConstraints, to avoid polluting this.options in case it is later used for a n:m
// Create a new options object for use with addForeignKeyConstraints, to avoid polluting this.options in case it is later used for a n:m
const
constraintOptions
=
_
.
clone
(
this
.
options
)
;
const
constraintOptions
=
{
...
this
.
options
}
;
newAttributes
[
this
.
foreignKey
]
=
_
.
defaults
({},
this
.
foreignKeyAttribute
,
{
newAttributes
[
this
.
foreignKey
]
=
_
.
defaults
({},
this
.
foreignKeyAttribute
,
{
type
:
this
.
options
.
keyType
||
this
.
source
.
rawAttributes
[
this
.
sourceKeyAttribute
].
type
,
type
:
this
.
options
.
keyType
||
this
.
source
.
rawAttributes
[
this
.
sourceKeyAttribute
].
type
,
...
...
lib/dialects/postgres/query-interface.js
View file @
8e4f4a9
...
@@ -3,8 +3,6 @@
...
@@ -3,8 +3,6 @@
const
DataTypes
=
require
(
'../../data-types'
);
const
DataTypes
=
require
(
'../../data-types'
);
const
Promise
=
require
(
'../../promise'
);
const
Promise
=
require
(
'../../promise'
);
const
QueryTypes
=
require
(
'../../query-types'
);
const
QueryTypes
=
require
(
'../../query-types'
);
const
_
=
require
(
'lodash'
);
/**
/**
Returns an object that handles Postgres special needs to do certain queries.
Returns an object that handles Postgres special needs to do certain queries.
...
@@ -76,7 +74,7 @@ function ensureEnums(qi, tableName, attributes, options, model) {
...
@@ -76,7 +74,7 @@ function ensureEnums(qi, tableName, attributes, options, model) {
vals
.
forEach
((
value
,
idx
)
=>
{
vals
.
forEach
((
value
,
idx
)
=>
{
// reset out after/before options since it's for every enum value
// reset out after/before options since it's for every enum value
const
valueOptions
=
_
.
clone
(
options
)
;
const
valueOptions
=
{
...
options
}
;
valueOptions
.
before
=
null
;
valueOptions
.
before
=
null
;
valueOptions
.
after
=
null
;
valueOptions
.
after
=
null
;
...
...
lib/dialects/sqlite/query-interface.js
View file @
8e4f4a9
'use strict'
;
'use strict'
;
const
_
=
require
(
'lodash'
);
const
Promise
=
require
(
'../../promise'
);
const
Promise
=
require
(
'../../promise'
);
const
sequelizeErrors
=
require
(
'../../errors'
);
const
sequelizeErrors
=
require
(
'../../errors'
);
const
QueryTypes
=
require
(
'../../query-types'
);
const
QueryTypes
=
require
(
'../../query-types'
);
...
@@ -89,7 +88,7 @@ function renameColumn(qi, tableName, attrNameBefore, attrNameAfter, options) {
...
@@ -89,7 +88,7 @@ function renameColumn(qi, tableName, attrNameBefore, attrNameAfter, options) {
options
=
options
||
{};
options
=
options
||
{};
return
qi
.
describeTable
(
tableName
,
options
).
then
(
fields
=>
{
return
qi
.
describeTable
(
tableName
,
options
).
then
(
fields
=>
{
fields
[
attrNameAfter
]
=
_
.
clone
(
fields
[
attrNameBefore
])
;
fields
[
attrNameAfter
]
=
{
...
fields
[
attrNameBefore
]
}
;
delete
fields
[
attrNameBefore
];
delete
fields
[
attrNameBefore
];
const
sql
=
qi
.
QueryGenerator
.
renameColumnQuery
(
tableName
,
attrNameBefore
,
attrNameAfter
,
fields
);
const
sql
=
qi
.
QueryGenerator
.
renameColumnQuery
(
tableName
,
attrNameBefore
,
attrNameAfter
,
fields
);
...
...
lib/instance-validator.js
View file @
8e4f4a9
...
@@ -18,7 +18,7 @@ const validator = require('./utils/validator-extras').validator;
...
@@ -18,7 +18,7 @@ const validator = require('./utils/validator-extras').validator;
*/
*/
class
InstanceValidator
{
class
InstanceValidator
{
constructor
(
modelInstance
,
options
)
{
constructor
(
modelInstance
,
options
)
{
options
=
_
.
clone
(
options
)
||
{
};
options
=
{
...
options
};
if
(
options
.
fields
&&
!
options
.
skip
)
{
if
(
options
.
fields
&&
!
options
.
skip
)
{
options
.
skip
=
_
.
difference
(
Object
.
keys
(
modelInstance
.
constructor
.
rawAttributes
),
options
.
fields
);
options
.
skip
=
_
.
difference
(
Object
.
keys
(
modelInstance
.
constructor
.
rawAttributes
),
options
.
fields
);
...
...
lib/model.js
View file @
8e4f4a9
...
@@ -122,7 +122,7 @@ class Model {
...
@@ -122,7 +122,7 @@ class Model {
let
defaults
;
let
defaults
;
let
key
;
let
key
;
values
=
values
&&
_
.
clone
(
values
)
||
{
};
values
=
values
&&
{
...
values
};
if
(
options
.
isNewRecord
)
{
if
(
options
.
isNewRecord
)
{
defaults
=
{};
defaults
=
{};
...
@@ -273,7 +273,7 @@ class Model {
...
@@ -273,7 +273,7 @@ class Model {
};
};
}
}
const
existingAttributes
=
_
.
clone
(
this
.
rawAttributes
)
;
const
existingAttributes
=
{
...
this
.
rawAttributes
}
;
this
.
rawAttributes
=
{};
this
.
rawAttributes
=
{};
_
.
each
(
head
,
(
value
,
attr
)
=>
{
_
.
each
(
head
,
(
value
,
attr
)
=>
{
...
@@ -2239,7 +2239,7 @@ class Model {
...
@@ -2239,7 +2239,7 @@ class Model {
return
this
.
findOne
(
options
).
then
(
instance
=>
{
return
this
.
findOne
(
options
).
then
(
instance
=>
{
if
(
instance
===
null
)
{
if
(
instance
===
null
)
{
values
=
_
.
clone
(
options
.
defaults
)
||
{
};
values
=
{
...
options
.
defaults
};
if
(
_
.
isPlainObject
(
options
.
where
))
{
if
(
_
.
isPlainObject
(
options
.
where
))
{
values
=
Utils
.
defaults
(
values
,
options
.
where
);
values
=
Utils
.
defaults
(
values
,
options
.
where
);
}
}
...
@@ -2312,7 +2312,7 @@ class Model {
...
@@ -2312,7 +2312,7 @@ class Model {
return
[
instance
,
false
];
return
[
instance
,
false
];
}
}
values
=
_
.
clone
(
options
.
defaults
)
||
{
};
values
=
{
...
options
.
defaults
};
if
(
_
.
isPlainObject
(
options
.
where
))
{
if
(
_
.
isPlainObject
(
options
.
where
))
{
values
=
Utils
.
defaults
(
values
,
options
.
where
);
values
=
Utils
.
defaults
(
values
,
options
.
where
);
}
}
...
@@ -2387,7 +2387,7 @@ class Model {
...
@@ -2387,7 +2387,7 @@ class Model {
);
);
}
}
let
values
=
_
.
clone
(
options
.
defaults
)
||
{
};
let
values
=
{
...
options
.
defaults
};
if
(
_
.
isPlainObject
(
options
.
where
))
{
if
(
_
.
isPlainObject
(
options
.
where
))
{
values
=
Utils
.
defaults
(
values
,
options
.
where
);
values
=
Utils
.
defaults
(
values
,
options
.
where
);
}
}
...
@@ -2571,7 +2571,7 @@ class Model {
...
@@ -2571,7 +2571,7 @@ class Model {
// Validate
// Validate
if
(
options
.
validate
)
{
if
(
options
.
validate
)
{
const
errors
=
new
Promise
.
AggregateError
();
const
errors
=
new
Promise
.
AggregateError
();
const
validateOptions
=
_
.
clone
(
options
)
;
const
validateOptions
=
{
...
options
}
;
validateOptions
.
hooks
=
options
.
individualHooks
;
validateOptions
.
hooks
=
options
.
individualHooks
;
return
Promise
.
map
(
instances
,
instance
=>
return
Promise
.
map
(
instances
,
instance
=>
...
@@ -2589,7 +2589,7 @@ class Model {
...
@@ -2589,7 +2589,7 @@ class Model {
if
(
options
.
individualHooks
)
{
if
(
options
.
individualHooks
)
{
// Create each instance individually
// Create each instance individually
return
Promise
.
map
(
instances
,
instance
=>
{
return
Promise
.
map
(
instances
,
instance
=>
{
const
individualOptions
=
_
.
clone
(
options
)
;
const
individualOptions
=
{
...
options
}
;
delete
individualOptions
.
fields
;
delete
individualOptions
.
fields
;
delete
individualOptions
.
individualHooks
;
delete
individualOptions
.
individualHooks
;
delete
individualOptions
.
ignoreDuplicates
;
delete
individualOptions
.
ignoreDuplicates
;
...
@@ -3018,7 +3018,7 @@ class Model {
...
@@ -3018,7 +3018,7 @@ class Model {
// Hooks change values in a different way for each record
// Hooks change values in a different way for each record
// Do not run original query but save each record individually
// Do not run original query but save each record individually
return
Promise
.
map
(
instances
,
instance
=>
{
return
Promise
.
map
(
instances
,
instance
=>
{
const
individualOptions
=
_
.
clone
(
options
)
;
const
individualOptions
=
{
...
options
}
;
delete
individualOptions
.
individualHooks
;
delete
individualOptions
.
individualHooks
;
individualOptions
.
hooks
=
false
;
individualOptions
.
hooks
=
false
;
individualOptions
.
validate
=
false
;
individualOptions
.
validate
=
false
;
...
@@ -3437,7 +3437,7 @@ class Model {
...
@@ -3437,7 +3437,7 @@ class Model {
this
.
dataValues
=
values
;
this
.
dataValues
=
values
;
}
}
// If raw, .changed() shouldn't be true
// If raw, .changed() shouldn't be true
this
.
_previousDataValues
=
_
.
clone
(
this
.
dataValues
)
;
this
.
_previousDataValues
=
{
...
this
.
dataValues
}
;
}
else
{
}
else
{
// Loop and call set
// Loop and call set
if
(
options
.
attributes
)
{
if
(
options
.
attributes
)
{
...
@@ -3464,7 +3464,7 @@ class Model {
...
@@ -3464,7 +3464,7 @@ class Model {
if
(
options
.
raw
)
{
if
(
options
.
raw
)
{
// If raw, .changed() shouldn't be true
// If raw, .changed() shouldn't be true
this
.
_previousDataValues
=
_
.
clone
(
this
.
dataValues
)
;
this
.
_previousDataValues
=
{
...
this
.
dataValues
}
;
}
}
}
}
return
this
;
return
this
;
...
...
lib/query-interface.js
View file @
8e4f4a9
...
@@ -194,7 +194,7 @@ class QueryInterface {
...
@@ -194,7 +194,7 @@ class QueryInterface {
let
sql
=
''
;
let
sql
=
''
;
let
promise
;
let
promise
;
options
=
_
.
clone
(
options
)
||
{
};
options
=
{
...
options
};
if
(
options
&&
options
.
uniqueKeys
)
{
if
(
options
&&
options
.
uniqueKeys
)
{
_
.
forOwn
(
options
.
uniqueKeys
,
uniqueKey
=>
{
_
.
forOwn
(
options
.
uniqueKeys
,
uniqueKey
=>
{
...
@@ -246,7 +246,7 @@ class QueryInterface {
...
@@ -246,7 +246,7 @@ class QueryInterface {
*/
*/
dropTable
(
tableName
,
options
)
{
dropTable
(
tableName
,
options
)
{
// if we're forcing we should be cascading unless explicitly stated otherwise
// if we're forcing we should be cascading unless explicitly stated otherwise
options
=
_
.
clone
(
options
)
||
{
};
options
=
{
...
options
};
options
.
cascade
=
options
.
cascade
||
options
.
force
||
false
;
options
.
cascade
=
options
.
cascade
||
options
.
force
||
false
;
let
sql
=
this
.
QueryGenerator
.
dropTableQuery
(
tableName
,
options
);
let
sql
=
this
.
QueryGenerator
.
dropTableQuery
(
tableName
,
options
);
...
@@ -906,7 +906,7 @@ class QueryInterface {
...
@@ -906,7 +906,7 @@ class QueryInterface {
let
indexes
=
[];
let
indexes
=
[];
let
indexFields
;
let
indexFields
;
options
=
_
.
clone
(
options
)
;
options
=
{
...
options
}
;
if
(
!
Utils
.
isWhereEmpty
(
where
))
{
if
(
!
Utils
.
isWhereEmpty
(
where
))
{
wheres
.
push
(
where
);
wheres
.
push
(
where
);
...
@@ -991,7 +991,7 @@ class QueryInterface {
...
@@ -991,7 +991,7 @@ class QueryInterface {
* @returns {Promise}
* @returns {Promise}
*/
*/
bulkInsert
(
tableName
,
records
,
options
,
attributes
)
{
bulkInsert
(
tableName
,
records
,
options
,
attributes
)
{
options
=
_
.
clone
(
options
)
||
{
};
options
=
{
...
options
};
options
.
type
=
QueryTypes
.
INSERT
;
options
.
type
=
QueryTypes
.
INSERT
;
return
this
.
sequelize
.
query
(
return
this
.
sequelize
.
query
(
...
@@ -1001,7 +1001,7 @@ class QueryInterface {
...
@@ -1001,7 +1001,7 @@ class QueryInterface {
}
}
update
(
instance
,
tableName
,
values
,
identifier
,
options
)
{
update
(
instance
,
tableName
,
values
,
identifier
,
options
)
{
options
=
_
.
clone
(
options
||
{})
;
options
=
{
...
options
||
{}
}
;
options
.
hasTrigger
=
!!
(
instance
&&
instance
.
_modelOptions
&&
instance
.
_modelOptions
.
hasTrigger
);
options
.
hasTrigger
=
!!
(
instance
&&
instance
.
_modelOptions
&&
instance
.
_modelOptions
.
hasTrigger
);
const
sql
=
this
.
QueryGenerator
.
updateQuery
(
tableName
,
values
,
identifier
,
options
,
instance
.
constructor
.
rawAttributes
);
const
sql
=
this
.
QueryGenerator
.
updateQuery
(
tableName
,
values
,
identifier
,
options
,
instance
.
constructor
.
rawAttributes
);
...
@@ -1047,7 +1047,7 @@ class QueryInterface {
...
@@ -1047,7 +1047,7 @@ class QueryInterface {
const
cascades
=
[];
const
cascades
=
[];
const
sql
=
this
.
QueryGenerator
.
deleteQuery
(
tableName
,
identifier
,
{},
instance
.
constructor
);
const
sql
=
this
.
QueryGenerator
.
deleteQuery
(
tableName
,
identifier
,
{},
instance
.
constructor
);
options
=
_
.
clone
(
options
)
||
{
};
options
=
{
...
options
};
// Check for a restrict field
// Check for a restrict field
if
(
!!
instance
.
constructor
&&
!!
instance
.
constructor
.
associations
)
{
if
(
!!
instance
.
constructor
&&
!!
instance
.
constructor
.
associations
)
{
...
...
lib/sequelize.js
View file @
8e4f4a9
...
@@ -771,7 +771,7 @@ class Sequelize {
...
@@ -771,7 +771,7 @@ class Sequelize {
* @returns {Promise}
* @returns {Promise}
*/
*/
sync
(
options
)
{
sync
(
options
)
{
options
=
_
.
clone
(
options
)
||
{
};
options
=
{
...
options
};
options
.
hooks
=
options
.
hooks
===
undefined
?
true
:
!!
options
.
hooks
;
options
.
hooks
=
options
.
hooks
===
undefined
?
true
:
!!
options
.
hooks
;
options
=
_
.
defaults
(
options
,
this
.
options
.
sync
,
this
.
options
);
options
=
_
.
defaults
(
options
,
this
.
options
.
sync
,
this
.
options
);
...
...
lib/utils.js
View file @
8e4f4a9
...
@@ -264,8 +264,11 @@ function toDefaultValue(value, dialect) {
...
@@ -264,8 +264,11 @@ function toDefaultValue(value, dialect) {
if
(
value
instanceof
DataTypes
.
NOW
)
{
if
(
value
instanceof
DataTypes
.
NOW
)
{
return
now
(
dialect
);
return
now
(
dialect
);
}
}
if
(
_
.
isPlainObject
(
value
)
||
Array
.
isArray
(
value
))
{
if
(
Array
.
isArray
(
value
))
{
return
_
.
clone
(
value
);
return
value
.
slice
(
0
);
}
if
(
_
.
isPlainObject
(
value
))
{
return
{
...
value
};
}
}
return
value
;
return
value
;
}
}
...
...
test/integration/dialects/abstract/connection-manager.test.js
View file @
8e4f4a9
'use strict'
;
'use strict'
;
const
chai
=
require
(
'chai'
),
const
chai
=
require
(
'chai'
);
expect
=
chai
.
expect
,
const
expect
=
chai
.
expect
;
Support
=
require
(
'../../support'
),
const
Support
=
require
(
'../../support'
);
sinon
=
require
(
'sinon'
),
const
sinon
=
require
(
'sinon'
);
Config
=
require
(
'../../../config/config'
),
const
Config
=
require
(
'../../../config/config'
);
ConnectionManager
=
require
(
'../../../../lib/dialects/abstract/connection-manager'
),
const
ConnectionManager
=
require
(
'../../../../lib/dialects/abstract/connection-manager'
);
Pool
=
require
(
'sequelize-pool'
).
Pool
,
const
Pool
=
require
(
'sequelize-pool'
).
Pool
;
_
=
require
(
'lodash'
);
const
baseConf
=
Config
[
Support
.
getTestDialect
()];
const
baseConf
=
Config
[
Support
.
getTestDialect
()];
const
poolEntry
=
{
const
poolEntry
=
{
...
@@ -44,8 +43,8 @@ describe('Connection Manager', () => {
...
@@ -44,8 +43,8 @@ describe('Connection Manager', () => {
it
(
'should initialize a multiple pools with replication'
,
()
=>
{
it
(
'should initialize a multiple pools with replication'
,
()
=>
{
const
options
=
{
const
options
=
{
replication
:
{
replication
:
{
write
:
_
.
clone
(
poolEntry
)
,
write
:
{
...
poolEntry
}
,
read
:
[
_
.
clone
(
poolEntry
),
_
.
clone
(
poolEntry
)
]
read
:
[
{
...
poolEntry
},
{
...
poolEntry
}
]
}
}
};
};
const
sequelize
=
Support
.
createSequelizeInstance
(
options
);
const
sequelize
=
Support
.
createSequelizeInstance
(
options
);
...
@@ -61,14 +60,14 @@ describe('Connection Manager', () => {
...
@@ -61,14 +60,14 @@ describe('Connection Manager', () => {
return
;
return
;
}
}
const
slave1
=
_
.
clone
(
poolEntry
)
;
const
slave1
=
{
...
poolEntry
}
;
const
slave2
=
_
.
clone
(
poolEntry
)
;
const
slave2
=
{
...
poolEntry
}
;
slave1
.
host
=
'slave1'
;
slave1
.
host
=
'slave1'
;
slave2
.
host
=
'slave2'
;
slave2
.
host
=
'slave2'
;
const
options
=
{
const
options
=
{
replication
:
{
replication
:
{
write
:
_
.
clone
(
poolEntry
)
,
write
:
{
...
poolEntry
}
,
read
:
[
slave1
,
slave2
]
read
:
[
slave1
,
slave2
]
}
}
};
};
...
@@ -107,13 +106,13 @@ describe('Connection Manager', () => {
...
@@ -107,13 +106,13 @@ describe('Connection Manager', () => {
});
});
it
(
'should allow forced reads from the write pool'
,
()
=>
{
it
(
'should allow forced reads from the write pool'
,
()
=>
{
const
master
=
_
.
clone
(
poolEntry
)
;
const
master
=
{
...
poolEntry
}
;
master
.
host
=
'the-boss'
;
master
.
host
=
'the-boss'
;
const
options
=
{
const
options
=
{
replication
:
{
replication
:
{
write
:
master
,
write
:
master
,
read
:
[
_
.
clone
(
poolEntry
)
]
read
:
[
{
...
poolEntry
}
]
}
}
};
};
const
sequelize
=
Support
.
createSequelizeInstance
(
options
);
const
sequelize
=
Support
.
createSequelizeInstance
(
options
);
...
...
test/unit/model/destroy.test.js
View file @
8e4f4a9
'use strict'
;
'use strict'
;
const
chai
=
require
(
'chai'
),
const
{
expect
}
=
require
(
'chai'
);
expect
=
chai
.
expect
,
const
Support
=
require
(
'../support'
);
Support
=
require
(
'../support'
),
const
current
=
Support
.
sequelize
;
current
=
Support
.
sequelize
,
const
sinon
=
require
(
'sinon'
);
sinon
=
require
(
'sinon'
),
const
DataTypes
=
require
(
'../../../lib/data-types'
);
DataTypes
=
require
(
'../../../lib/data-types'
),
_
=
require
(
'lodash'
);
describe
(
Support
.
getTestDialectTeaser
(
'Model'
),
()
=>
{
describe
(
Support
.
getTestDialectTeaser
(
'Model'
),
()
=>
{
...
@@ -22,7 +20,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -22,7 +20,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
beforeEach
(
function
()
{
beforeEach
(
function
()
{
this
.
deloptions
=
{
where
:
{
secretValue
:
'1'
}
};
this
.
deloptions
=
{
where
:
{
secretValue
:
'1'
}
};
this
.
cloneOptions
=
_
.
clone
(
this
.
deloptions
)
;
this
.
cloneOptions
=
{
...
this
.
deloptions
}
;
this
.
stubDelete
.
resetHistory
();
this
.
stubDelete
.
resetHistory
();
});
});
...
...
test/unit/model/update.test.js
View file @
8e4f4a9
'use strict'
;
'use strict'
;
const
chai
=
require
(
'chai'
),
const
{
expect
}
=
require
(
'chai'
);
expect
=
chai
.
expect
,
const
Support
=
require
(
'../support'
);
Support
=
require
(
'../support'
),
const
current
=
Support
.
sequelize
;
current
=
Support
.
sequelize
,
const
sinon
=
require
(
'sinon'
);
sinon
=
require
(
'sinon'
),
const
DataTypes
=
require
(
'../../../lib/data-types'
);
DataTypes
=
require
(
'../../../lib/data-types'
),
_
=
require
(
'lodash'
);
describe
(
Support
.
getTestDialectTeaser
(
'Model'
),
()
=>
{
describe
(
Support
.
getTestDialectTeaser
(
'Model'
),
()
=>
{
describe
(
'method update'
,
()
=>
{
describe
(
'method update'
,
()
=>
{
...
@@ -20,7 +18,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
...
@@ -20,7 +18,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
beforeEach
(
function
()
{
beforeEach
(
function
()
{
this
.
stubUpdate
=
sinon
.
stub
(
current
.
getQueryInterface
(),
'bulkUpdate'
).
resolves
([]);
this
.
stubUpdate
=
sinon
.
stub
(
current
.
getQueryInterface
(),
'bulkUpdate'
).
resolves
([]);
this
.
updates
=
{
name
:
'Batman'
,
secretValue
:
'7'
};
this
.
updates
=
{
name
:
'Batman'
,
secretValue
:
'7'
};
this
.
cloneUpdates
=
_
.
clone
(
this
.
updates
)
;
this
.
cloneUpdates
=
{
...
this
.
updates
}
;
});
});
afterEach
(
function
()
{
afterEach
(
function
()
{
...
...
test/unit/sql/create-table.test.js
View file @
8e4f4a9
...
@@ -86,7 +86,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
...
@@ -86,7 +86,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
if
(
current
.
dialect
.
name
===
'postgres'
)
{
if
(
current
.
dialect
.
name
===
'postgres'
)
{
describe
(
'IF NOT EXISTS version check'
,
()
=>
{
describe
(
'IF NOT EXISTS version check'
,
()
=>
{
const
modifiedSQL
=
_
.
clone
(
sql
)
;
const
modifiedSQL
=
{
...
sql
}
;
const
createTableQueryModified
=
sql
.
createTableQuery
.
bind
(
modifiedSQL
);
const
createTableQueryModified
=
sql
.
createTableQuery
.
bind
(
modifiedSQL
);
it
(
'it will not have IF NOT EXISTS for version 9.0 or below'
,
()
=>
{
it
(
'it will not have IF NOT EXISTS for version 9.0 or below'
,
()
=>
{
modifiedSQL
.
sequelize
.
options
.
databaseVersion
=
'9.0.0'
;
modifiedSQL
.
sequelize
.
options
.
databaseVersion
=
'9.0.0'
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment