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 cf8cd6eb
authored
Nov 22, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into features/transactions
Conflicts: lib/dialects/sqlite/query.js
2 parents
06b8b2bf
53007f22
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
40 additions
and
9 deletions
Makefile
lib/associations/has-many-double-linked.js
lib/associations/has-many-single-linked.js
lib/associations/has-one.js
lib/dao-factory.js
lib/dao.js
lib/dialects/mariadb/query.js
lib/dialects/postgres/connector-manager.js
lib/dialects/postgres/query-generator.js
lib/dialects/sqlite/query.js
lib/query-interface.js
test/hooks.test.js
Makefile
View file @
cf8cd6e
...
@@ -13,9 +13,9 @@ teaser:
...
@@ -13,9 +13,9 @@ teaser:
test
:
test
:
@
if
[
"
$$
GREP"
]
;
then
\
@
if
[
"
$$
GREP"
]
;
then
\
make teaser
&&
./node_modules/mocha/bin/mocha --colors -t 10000 --reporter
$(REPORTER)
-g
"
$$
GREP"
$(TESTS)
;
\
make teaser
&&
./node_modules/mocha/bin/mocha --c
heck-leaks --c
olors -t 10000 --reporter
$(REPORTER)
-g
"
$$
GREP"
$(TESTS)
;
\
else
\
else
\
make teaser
&&
./node_modules/mocha/bin/mocha --colors -t 10000 --reporter
$(REPORTER)
$(TESTS)
;
\
make teaser
&&
./node_modules/mocha/bin/mocha --c
heck-leaks --c
olors -t 10000 --reporter
$(REPORTER)
$(TESTS)
;
\
fi
fi
...
...
lib/associations/has-many-double-linked.js
View file @
cf8cd6e
...
@@ -11,7 +11,9 @@ module.exports = (function() {
...
@@ -11,7 +11,9 @@ module.exports = (function() {
}
}
HasManyDoubleLinked
.
prototype
.
injectGetter
=
function
(
options
)
{
HasManyDoubleLinked
.
prototype
.
injectGetter
=
function
(
options
)
{
var
self
=
this
,
_options
=
options
var
self
=
this
,
_options
=
options
,
smart
var
customEventEmitter
=
new
Utils
.
CustomEventEmitter
(
function
()
{
var
customEventEmitter
=
new
Utils
.
CustomEventEmitter
(
function
()
{
var
where
=
{}
var
where
=
{}
...
...
lib/associations/has-many-single-linked.js
View file @
cf8cd6e
...
@@ -10,6 +10,7 @@ module.exports = (function() {
...
@@ -10,6 +10,7 @@ module.exports = (function() {
HasManySingleLinked
.
prototype
.
injectGetter
=
function
(
options
)
{
HasManySingleLinked
.
prototype
.
injectGetter
=
function
(
options
)
{
var
self
=
this
var
self
=
this
,
where
=
{}
,
where
=
{}
,
smart
options
=
options
||
{}
options
=
options
||
{}
var
primaryKey
=
Object
.
keys
(
this
.
instance
.
rawAttributes
).
filter
(
function
(
k
)
{
return
self
.
instance
.
rawAttributes
[
k
].
primaryKey
===
true
})
var
primaryKey
=
Object
.
keys
(
this
.
instance
.
rawAttributes
).
filter
(
function
(
k
)
{
return
self
.
instance
.
rawAttributes
[
k
].
primaryKey
===
true
})
...
...
lib/associations/has-one.js
View file @
cf8cd6e
...
@@ -45,6 +45,7 @@ module.exports = (function() {
...
@@ -45,6 +45,7 @@ module.exports = (function() {
HasOne
.
prototype
.
injectGetter
=
function
(
obj
)
{
HasOne
.
prototype
.
injectGetter
=
function
(
obj
)
{
var
self
=
this
var
self
=
this
,
smart
obj
[
this
.
accessors
.
get
]
=
function
(
params
)
{
obj
[
this
.
accessors
.
get
]
=
function
(
params
)
{
var
primaryKeys
=
Object
.
keys
(
this
.
daoFactory
.
primaryKeys
)
var
primaryKeys
=
Object
.
keys
(
this
.
daoFactory
.
primaryKeys
)
...
...
lib/dao-factory.js
View file @
cf8cd6e
...
@@ -259,6 +259,7 @@ module.exports = (function() {
...
@@ -259,6 +259,7 @@ module.exports = (function() {
,
i
,
i
,
scope
,
scope
,
scopeName
,
scopeName
,
scopeOptions
,
argLength
=
arguments
.
length
,
argLength
=
arguments
.
length
,
lastArg
=
arguments
[
argLength
-
1
]
,
lastArg
=
arguments
[
argLength
-
1
]
...
...
lib/dao.js
View file @
cf8cd6e
...
@@ -139,6 +139,7 @@ module.exports = (function() {
...
@@ -139,6 +139,7 @@ module.exports = (function() {
,
isEnum
=
definition
.
type
&&
(
definition
.
type
.
toString
()
===
DataTypes
.
ENUM
.
toString
())
,
isEnum
=
definition
.
type
&&
(
definition
.
type
.
toString
()
===
DataTypes
.
ENUM
.
toString
())
,
isMySQL
=
[
'mysql'
,
'mariadb'
].
indexOf
(
self
.
daoFactory
.
daoFactoryManager
.
sequelize
.
options
.
dialect
)
!==
-
1
,
isMySQL
=
[
'mysql'
,
'mariadb'
].
indexOf
(
self
.
daoFactory
.
daoFactoryManager
.
sequelize
.
options
.
dialect
)
!==
-
1
,
ciCollation
=
!!
self
.
daoFactory
.
options
.
collate
&&
self
.
daoFactory
.
options
.
collate
.
match
(
/_ci$/i
)
,
ciCollation
=
!!
self
.
daoFactory
.
options
.
collate
&&
self
.
daoFactory
.
options
.
collate
.
match
(
/_ci$/i
)
,
valueOutOfScope
// Unfortunately for MySQL CI collation we need to map/lowercase values again
// Unfortunately for MySQL CI collation we need to map/lowercase values again
if
(
isEnum
&&
isMySQL
&&
ciCollation
&&
(
attrName
in
values
)
&&
values
[
attrName
])
{
if
(
isEnum
&&
isMySQL
&&
ciCollation
&&
(
attrName
in
values
)
&&
values
[
attrName
])
{
...
...
lib/dialects/mariadb/query.js
View file @
cf8cd6e
...
@@ -32,6 +32,8 @@ module.exports = (function() {
...
@@ -32,6 +32,8 @@ module.exports = (function() {
.
on
(
'result'
,
function
(
results
)
{
.
on
(
'result'
,
function
(
results
)
{
results
results
.
on
(
'row'
,
function
(
row
,
metadata
)
{
.
on
(
'row'
,
function
(
row
,
metadata
)
{
var
type
for
(
var
prop
in
row
)
{
for
(
var
prop
in
row
)
{
if
(
row
.
hasOwnProperty
(
prop
))
{
if
(
row
.
hasOwnProperty
(
prop
))
{
if
(
row
[
prop
]
===
null
)
{
if
(
row
[
prop
]
===
null
)
{
...
...
lib/dialects/postgres/connector-manager.js
View file @
cf8cd6e
...
@@ -61,7 +61,9 @@ module.exports = (function() {
...
@@ -61,7 +61,9 @@ module.exports = (function() {
var
query
=
new
Query
(
self
.
client
,
self
.
sequelize
,
callee
,
options
||
{})
var
query
=
new
Query
(
self
.
client
,
self
.
sequelize
,
callee
,
options
||
{})
return
query
.
run
(
sql
)
return
query
.
run
(
sql
)
.
complete
(
function
(
err
)
{
done
&&
done
(
err
)
})
.
complete
(
function
(
err
)
{
self
.
endQuery
.
call
(
self
)
done
&&
done
(
err
)
})
.
success
(
function
(
results
)
{
self
.
endQuery
.
call
(
self
)
})
.
success
(
function
(
results
)
{
self
.
endQuery
.
call
(
self
)
})
.
error
(
function
(
err
)
{
self
.
endQuery
.
call
(
self
)
})
.
error
(
function
(
err
)
{
self
.
endQuery
.
call
(
self
)
})
.
proxy
(
emitter
)
.
proxy
(
emitter
)
...
...
lib/dialects/postgres/query-generator.js
View file @
cf8cd6e
...
@@ -145,10 +145,14 @@ module.exports = (function() {
...
@@ -145,10 +145,14 @@ module.exports = (function() {
},
},
arrayValue
:
function
(
value
,
key
,
_key
,
factory
){
arrayValue
:
function
(
value
,
key
,
_key
,
factory
){
var
col
=
null
,
coltype
=
null
,
_realKey
=
key
.
split
(
'.'
).
pop
()
,
_value
if
(
value
.
length
===
0
)
{
value
=
[
null
]
}
if
(
value
.
length
===
0
)
{
value
=
[
null
]
}
var
col
=
null
,
coltype
=
null
// Special conditions for searching within an array column type
// Special conditions for searching within an array column type
var
_realKey
=
key
.
split
(
'.'
).
pop
()
if
(
!!
factory
&&
!!
factory
.
rawAttributes
[
_realKey
])
{
if
(
!!
factory
&&
!!
factory
.
rawAttributes
[
_realKey
])
{
col
=
factory
.
rawAttributes
[
_realKey
]
col
=
factory
.
rawAttributes
[
_realKey
]
coltype
=
col
.
type
coltype
=
col
.
type
...
...
lib/dialects/sqlite/query.js
View file @
cf8cd6e
...
@@ -42,8 +42,13 @@ module.exports = (function() {
...
@@ -42,8 +42,13 @@ module.exports = (function() {
self
.
database
[
getDatabaseMethod
.
call
(
self
)](
self
.
sql
,
function
(
err
,
results
)
{
self
.
database
[
getDatabaseMethod
.
call
(
self
)](
self
.
sql
,
function
(
err
,
results
)
{
// allow clients to listen to sql to do their own logging or whatnot
// allow clients to listen to sql to do their own logging or whatnot
self
.
emit
(
'sql'
,
self
.
sql
)
self
.
emit
(
'sql'
,
self
.
sql
)
this
.
columnTypes
=
columnTypes
;
err
?
onFailure
.
call
(
self
,
err
)
:
onSuccess
.
call
(
self
,
results
,
this
)
if
(
err
)
{
onFailure
.
call
(
self
,
err
)
}
else
{
this
.
columnTypes
=
columnTypes
onSuccess
.
call
(
self
,
results
,
this
)
}
})
})
}
}
}
}
...
...
lib/query-interface.js
View file @
cf8cd6e
...
@@ -817,7 +817,7 @@ module.exports = (function() {
...
@@ -817,7 +817,7 @@ module.exports = (function() {
QueryInterface
.
prototype
.
setIsolationLevel
=
function
(
transaction
,
value
)
{
QueryInterface
.
prototype
.
setIsolationLevel
=
function
(
transaction
,
value
)
{
if
(
!
transaction
||
!
(
transaction
instanceof
Transaction
))
{
if
(
!
transaction
||
!
(
transaction
instanceof
Transaction
))
{
throw
new
Error
(
'Unable to set isolati
p
n level for a transaction without transaction object!'
)
throw
new
Error
(
'Unable to set isolati
o
n level for a transaction without transaction object!'
)
}
}
var
sql
=
this
.
QueryGenerator
.
setIsolationLevelQuery
(
value
)
var
sql
=
this
.
QueryGenerator
.
setIsolationLevelQuery
(
value
)
...
...
test/hooks.test.js
View file @
cf8cd6e
...
@@ -6087,6 +6087,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
...
@@ -6087,6 +6087,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
})
})
it
(
'on success'
,
function
(
done
)
{
it
(
'on success'
,
function
(
done
)
{
var
beforeHook
,
afterHook
this
.
User
.
beforeDelete
(
function
(
user
,
fn
)
{
this
.
User
.
beforeDelete
(
function
(
user
,
fn
)
{
beforeHook
=
true
beforeHook
=
true
fn
()
fn
()
...
@@ -6107,6 +6110,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
...
@@ -6107,6 +6110,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
})
})
it
(
'on error'
,
function
(
done
)
{
it
(
'on error'
,
function
(
done
)
{
var
beforeHook
,
afterHook
this
.
User
.
beforeDelete
(
function
(
user
,
fn
)
{
this
.
User
.
beforeDelete
(
function
(
user
,
fn
)
{
beforeHook
=
true
beforeHook
=
true
fn
()
fn
()
...
@@ -6142,6 +6148,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
...
@@ -6142,6 +6148,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
})
})
it
(
'on success'
,
function
(
done
)
{
it
(
'on success'
,
function
(
done
)
{
var
beforeHook
,
afterHook
this
.
User
.
hook
(
'beforeDelete'
,
function
(
user
,
fn
)
{
this
.
User
.
hook
(
'beforeDelete'
,
function
(
user
,
fn
)
{
beforeHook
=
true
beforeHook
=
true
fn
()
fn
()
...
@@ -6162,6 +6171,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
...
@@ -6162,6 +6171,9 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
})
})
it
(
'on error'
,
function
(
done
)
{
it
(
'on error'
,
function
(
done
)
{
var
beforeHook
,
afterHook
this
.
User
.
hook
(
'beforeDelete'
,
function
(
user
,
fn
)
{
this
.
User
.
hook
(
'beforeDelete'
,
function
(
user
,
fn
)
{
beforeHook
=
true
beforeHook
=
true
fn
()
fn
()
...
...
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