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 92615757
authored
Jan 10, 2013
by
Thomas Watson Steen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ES5 `Object.keys` instead of Underscore.js `keys`
1 parent
c05f7acc
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
15 additions
and
15 deletions
lib/associations/has-many-double-linked.js
lib/dao-factory.js
lib/dao.js
lib/dialects/abstract/query.js
lib/dialects/mysql/query-generator.js
lib/dialects/postgres/query-generator.js
lib/dialects/sqlite/query-generator.js
lib/utils.js
lib/associations/has-many-double-linked.js
View file @
9261575
...
...
@@ -15,7 +15,7 @@ module.exports = (function() {
//fully qualify
where
[
self
.
__factory
.
connectorDAO
.
tableName
+
"."
+
self
.
__factory
.
identifier
]
=
self
.
instance
.
id
var
primaryKeys
=
Utils
.
_
.
keys
(
self
.
__factory
.
connectorDAO
.
rawAttributes
)
var
primaryKeys
=
Object
.
keys
(
self
.
__factory
.
connectorDAO
.
rawAttributes
)
,
foreignKey
=
primaryKeys
.
filter
(
function
(
pk
)
{
return
pk
!=
self
.
__factory
.
identifier
})[
0
]
where
[
self
.
__factory
.
connectorDAO
.
tableName
+
"."
+
foreignKey
]
=
{
join
:
self
.
__factory
.
target
.
tableName
+
".id"
}
...
...
@@ -85,7 +85,7 @@ module.exports = (function() {
obsoleteAssociations
.
forEach
(
function
(
associatedObject
)
{
var
where
=
{}
,
primaryKeys
=
Utils
.
_
.
keys
(
self
.
__factory
.
connectorDAO
.
rawAttributes
)
,
primaryKeys
=
Object
.
keys
(
self
.
__factory
.
connectorDAO
.
rawAttributes
)
,
foreignKey
=
primaryKeys
.
filter
(
function
(
pk
)
{
return
pk
!=
self
.
__factory
.
identifier
})[
0
]
,
notFoundEmitters
=
[]
...
...
lib/dao-factory.js
View file @
9261575
...
...
@@ -60,7 +60,7 @@ module.exports = (function() {
}
})
this
.
primaryKeyCount
=
Utils
.
_
.
keys
(
this
.
primaryKeys
).
length
;
this
.
primaryKeyCount
=
Object
.
keys
(
this
.
primaryKeys
).
length
;
this
.
options
.
hasPrimaryKeys
=
this
.
hasPrimaryKeys
=
this
.
primaryKeyCount
>
0
;
addDefaultAttributes
.
call
(
this
)
...
...
@@ -182,7 +182,7 @@ module.exports = (function() {
}
else
if
(
Utils
.
_
.
size
(
primaryKeys
)
&&
Utils
.
argsArePrimaryKeys
(
arguments
,
primaryKeys
))
{
var
where
=
{}
,
self
=
this
,
keys
=
Utils
.
_
.
keys
(
primaryKeys
)
,
keys
=
Object
.
keys
(
primaryKeys
)
Utils
.
_
.
each
(
arguments
,
function
(
arg
,
i
)
{
var
key
=
keys
[
i
]
...
...
lib/dao.js
View file @
9261575
...
...
@@ -74,7 +74,7 @@ module.exports = (function() {
Object
.
defineProperty
(
DAO
.
prototype
,
"identifiers"
,
{
get
:
function
()
{
var
primaryKeys
=
Utils
.
_
.
keys
(
this
.
__factory
.
primaryKeys
)
var
primaryKeys
=
Object
.
keys
(
this
.
__factory
.
primaryKeys
)
,
result
=
{}
,
self
=
this
...
...
@@ -203,7 +203,7 @@ module.exports = (function() {
DAO
.
prototype
.
setAttributes
=
function
(
updates
)
{
var
self
=
this
var
readOnlyAttributes
=
Utils
.
_
.
keys
(
this
.
__factory
.
primaryKeys
)
var
readOnlyAttributes
=
Object
.
keys
(
this
.
__factory
.
primaryKeys
)
readOnlyAttributes
.
push
(
'id'
)
readOnlyAttributes
.
push
(
'createdAt'
)
...
...
lib/dialects/abstract/query.js
View file @
9261575
...
...
@@ -168,7 +168,7 @@ module.exports = (function() {
var
queryResultHasJoin
=
function
(
results
)
{
if
(
!!
results
[
0
])
{
var
keys
=
Utils
.
_
.
keys
(
results
[
0
])
var
keys
=
Object
.
keys
(
results
[
0
])
for
(
var
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
if
(
!!
findTableNameInAttribute
.
call
(
this
,
keys
[
i
]))
{
...
...
lib/dialects/mysql/query-generator.js
View file @
9261575
...
...
@@ -141,7 +141,7 @@ module.exports = (function() {
,
association
=
dao
.
getAssociation
(
daoFactory
)
if
(
association
.
connectorDAO
)
{
var
foreignIdentifier
=
Utils
.
_
.
keys
(
association
.
connectorDAO
.
rawAttributes
).
filter
(
function
(
attrName
)
{
var
foreignIdentifier
=
Object
.
keys
(
association
.
connectorDAO
.
rawAttributes
).
filter
(
function
(
attrName
)
{
return
(
!!
attrName
.
match
(
/.+Id$/
)
||
!!
attrName
.
match
(
/.+_id$/
))
&&
(
attrName
!==
association
.
identifier
)
})[
0
]
...
...
@@ -165,7 +165,7 @@ module.exports = (function() {
,
aliasName
=
!!
aliasAssoc
?
Utils
.
addTicks
(
daoName
)
:
_tableName
optAttributes
=
optAttributes
.
concat
(
Utils
.
_
.
keys
(
dao
.
attributes
).
map
(
function
(
attr
)
{
Object
.
keys
(
dao
.
attributes
).
map
(
function
(
attr
)
{
return
''
+
[
_tableName
,
Utils
.
addTicks
(
attr
)].
join
(
'.'
)
+
' AS '
+
...
...
@@ -213,7 +213,7 @@ module.exports = (function() {
var
replacements
=
{
table
:
Utils
.
addTicks
(
tableName
),
attributes
:
Utils
.
_
.
keys
(
attrValueHash
).
map
(
function
(
attr
){
return
Utils
.
addTicks
(
attr
)}).
join
(
","
),
attributes
:
Object
.
keys
(
attrValueHash
).
map
(
function
(
attr
){
return
Utils
.
addTicks
(
attr
)}).
join
(
","
),
values
:
Utils
.
_
.
values
(
attrValueHash
).
map
(
function
(
value
){
return
Utils
.
escape
((
value
instanceof
Date
)
?
Utils
.
toSqlDate
(
value
)
:
value
)
}).
join
(
","
)
...
...
lib/dialects/postgres/query-generator.js
View file @
9261575
...
...
@@ -216,7 +216,7 @@ module.exports = (function() {
,
association
=
dao
.
getAssociation
(
daoFactory
)
if
(
association
.
connectorDAO
)
{
var
foreignIdentifier
=
Utils
.
_
.
keys
(
association
.
connectorDAO
.
rawAttributes
).
filter
(
function
(
attrName
)
{
var
foreignIdentifier
=
Object
.
keys
(
association
.
connectorDAO
.
rawAttributes
).
filter
(
function
(
attrName
)
{
return
(
!!
attrName
.
match
(
/.+Id$/
)
||
!!
attrName
.
match
(
/.+_id$/
))
&&
(
attrName
!==
association
.
identifier
)
})[
0
]
...
...
@@ -240,7 +240,7 @@ module.exports = (function() {
,
aliasName
=
!!
aliasAssoc
?
addQuotes
(
daoName
)
:
_tableName
optAttributes
=
optAttributes
.
concat
(
Utils
.
_
.
keys
(
dao
.
attributes
).
map
(
function
(
attr
)
{
Object
.
keys
(
dao
.
attributes
).
map
(
function
(
attr
)
{
return
''
+
[
_tableName
,
addQuotes
(
attr
)].
join
(
'.'
)
+
' AS "'
+
...
...
@@ -302,7 +302,7 @@ module.exports = (function() {
var
replacements
=
{
table
:
addQuotes
(
tableName
),
attributes
:
Utils
.
_
.
keys
(
attrValueHash
).
map
(
function
(
attr
){
return
addQuotes
(
attr
)}).
join
(
","
),
attributes
:
Object
.
keys
(
attrValueHash
).
map
(
function
(
attr
){
return
addQuotes
(
attr
)}).
join
(
","
),
values
:
Utils
.
_
.
values
(
attrValueHash
).
map
(
function
(
value
){
return
pgEscape
(
value
)
}).
join
(
","
)
...
...
lib/dialects/sqlite/query-generator.js
View file @
9261575
...
...
@@ -71,7 +71,7 @@ module.exports = (function() {
var
replacements
=
{
table
:
Utils
.
addTicks
(
tableName
),
attributes
:
Utils
.
_
.
keys
(
attrValueHash
).
map
(
function
(
attr
){
return
Utils
.
addTicks
(
attr
)}).
join
(
","
),
attributes
:
Object
.
keys
(
attrValueHash
).
map
(
function
(
attr
){
return
Utils
.
addTicks
(
attr
)}).
join
(
","
),
values
:
Utils
.
_
.
values
(
attrValueHash
).
map
(
function
(
value
){
return
escape
((
value
instanceof
Date
)
?
Utils
.
toSqlDate
(
value
)
:
value
)
}).
join
(
","
)
...
...
lib/utils.js
View file @
9261575
...
...
@@ -63,7 +63,7 @@ var Utils = module.exports = {
].
join
(
" "
)
},
argsArePrimaryKeys
:
function
(
args
,
primaryKeys
)
{
var
result
=
(
args
.
length
==
Utils
.
_
.
keys
(
primaryKeys
).
length
)
var
result
=
(
args
.
length
==
Object
.
keys
(
primaryKeys
).
length
)
if
(
result
)
{
Utils
.
_
.
each
(
args
,
function
(
arg
)
{
if
(
result
)
{
...
...
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