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 027d914e
authored
Mar 08, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better (and worse code) quote table logic
1 parent
64fb3354
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
27 deletions
lib/dialects/abstract/query-generator.js
lib/utils.js
test/associations/belongs-to.test.js
lib/dialects/abstract/query-generator.js
View file @
027d914
...
...
@@ -945,6 +945,8 @@ module.exports = (function() {
,
where
=
{}
,
self
=
this
options
=
options
||
{}
if
(
typeof
prepend
===
'undefined'
)
{
prepend
=
true
}
...
...
@@ -959,7 +961,8 @@ module.exports = (function() {
result
=
"("
+
result
+
")"
}
else
if
(
Utils
.
isHash
(
smth
))
{
if
(
prepend
)
{
smth
=
Utils
.
prependTableNameToHash
(
tableName
,
smth
,
self
.
quoteIdentifier
.
bind
(
self
))
options
.
keysEscaped
=
true
smth
=
this
.
prependTableNameToHash
(
tableName
,
smth
)
}
result
=
this
.
hashToWhereConditions
(
smth
,
factory
,
options
)
}
else
if
(
typeof
smth
===
'number'
)
{
...
...
@@ -973,7 +976,9 @@ module.exports = (function() {
}
where
[
primaryKeys
]
=
smth
smth
=
Utils
.
prependTableNameToHash
(
tableName
,
where
)
options
.
keysEscaped
=
true
smth
=
this
.
prependTableNameToHash
(
tableName
,
where
)
result
=
this
.
hashToWhereConditions
(
smth
)
}
else
if
(
typeof
smth
===
"string"
)
{
result
=
smth
...
...
@@ -999,6 +1004,30 @@ module.exports = (function() {
return
result
?
result
:
'1=1'
},
prependTableNameToHash
:
function
(
tableName
,
hash
)
{
if
(
tableName
)
{
var
_hash
=
{}
for
(
var
key
in
hash
)
{
if
(
key
instanceof
Utils
.
literal
)
{
_hash
[
key
]
=
hash
[
key
]
}
else
if
(
key
.
indexOf
(
'.'
)
===
-
1
)
{
if
(
tableName
instanceof
Utils
.
literal
)
{
_hash
[
tableName
+
'.'
+
this
.
quoteIdentifier
(
key
)]
=
hash
[
key
]
}
else
{
_hash
[
this
.
quoteTable
(
tableName
)
+
'.'
+
this
.
quoteIdentifier
(
key
)]
=
hash
[
key
]
}
}
else
{
_hash
[
this
.
quoteIdentifiers
(
key
)]
=
hash
[
key
]
}
}
return
_hash
}
else
{
return
hash
}
},
findAssociation
:
function
(
attribute
,
dao
){
var
associationToReturn
;
...
...
lib/utils.js
View file @
027d914
...
...
@@ -445,30 +445,6 @@ var Utils = module.exports = {
return
result
},
prependTableNameToHash
:
function
(
tableName
,
hash
,
quote
)
{
if
(
tableName
)
{
var
_hash
=
{}
for
(
var
key
in
hash
)
{
if
(
key
instanceof
Utils
.
literal
)
{
_hash
[
key
]
=
hash
[
key
]
}
else
if
(
key
.
indexOf
(
'.'
)
===
-
1
)
{
if
(
tableName
instanceof
Utils
.
literal
)
{
_hash
[
tableName
+
'.'
+
quote
(
key
)]
=
hash
[
key
]
}
else
{
_hash
[
tableName
+
'.'
+
key
]
=
hash
[
key
]
}
}
else
{
_hash
[
key
]
=
hash
[
key
]
}
}
return
_hash
}
else
{
return
hash
}
},
firstValueOfHash
:
function
(
obj
)
{
for
(
var
key
in
obj
)
{
if
(
obj
.
hasOwnProperty
(
key
))
...
...
test/associations/belongs-to.test.js
View file @
027d914
...
...
@@ -76,7 +76,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
})
})
it
.
only
(
'supports schemas'
,
function
(
done
)
{
it
(
'supports schemas'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'UserXYZ'
,
{
username
:
Sequelize
.
STRING
,
gender
:
Sequelize
.
STRING
}).
schema
(
'archive'
)
,
Task
=
this
.
sequelize
.
define
(
'TaskXYZ'
,
{
title
:
Sequelize
.
STRING
,
status
:
Sequelize
.
STRING
}).
schema
(
'archive'
)
,
self
=
this
...
...
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