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 d2e9adcb
authored
May 06, 2013
by
Martin Aspeli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rebase onto sequelize master and reflect MySQL query generator refactoring there
1 parent
3b951e13
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
lib/dialects/mysql/query-generator.js
lib/dialects/postgres/query.js
lib/dialects/mysql/query-generator.js
View file @
d2e9adc
...
@@ -244,8 +244,7 @@ module.exports = (function() {
...
@@ -244,8 +244,7 @@ module.exports = (function() {
},
},
bulkInsertQuery
:
function
(
tableName
,
attrValueHashes
)
{
bulkInsertQuery
:
function
(
tableName
,
attrValueHashes
)
{
var
query
=
"INSERT INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %>;"
var
tuples
=
[]
,
tuples
=
[]
Utils
.
_
.
forEach
(
attrValueHashes
,
function
(
attrValueHash
)
{
Utils
.
_
.
forEach
(
attrValueHashes
,
function
(
attrValueHash
)
{
tuples
.
push
(
"("
+
tuples
.
push
(
"("
+
...
@@ -255,13 +254,12 @@ module.exports = (function() {
...
@@ -255,13 +254,12 @@ module.exports = (function() {
")"
)
")"
)
})
})
var
replacements
=
{
var
table
=
QueryGenerator
.
addQuotes
(
tableName
)
table
:
QueryGenerator
.
addQuotes
(
tableName
),
var
attributes
=
Object
.
keys
(
attrValueHashes
[
0
]).
map
(
function
(
attr
){
return
QueryGenerator
.
addQuotes
(
attr
)}).
join
(
","
)
attributes
:
Object
.
keys
(
attrValueHashes
[
0
]).
map
(
function
(
attr
){
return
QueryGenerator
.
addQuotes
(
attr
)}).
join
(
","
),
tuples
:
tuples
.
join
(
","
)
}
return
Utils
.
_
.
template
(
query
)(
replacements
)
var
query
=
"INSERT INTO "
+
table
+
" ("
+
attributes
+
") VALUES "
+
tuples
.
join
(
","
)
+
";"
return
query
},
},
updateQuery
:
function
(
tableName
,
attrValueHash
,
where
)
{
updateQuery
:
function
(
tableName
,
attrValueHash
,
where
)
{
...
@@ -306,13 +304,12 @@ module.exports = (function() {
...
@@ -306,13 +304,12 @@ module.exports = (function() {
bulkDeleteQuery
:
function
(
tableName
,
where
,
options
)
{
bulkDeleteQuery
:
function
(
tableName
,
where
,
options
)
{
options
=
options
||
{}
options
=
options
||
{}
var
query
=
"DELETE FROM <%= table %> WHERE <%= where %>"
var
table
=
QueryGenerator
.
addQuotes
(
tableName
)
var
replacements
=
{
var
where
=
QueryGenerator
.
getWhereConditions
(
where
)
table
:
QueryGenerator
.
addQuotes
(
tableName
),
where
:
QueryGenerator
.
getWhereConditions
(
where
)
}
return
Utils
.
_
.
template
(
query
)(
replacements
)
var
query
=
"DELETE FROM "
+
table
+
" WHERE "
+
where
return
query
},
},
incrementQuery
:
function
(
tableName
,
attrValueHash
,
where
)
{
incrementQuery
:
function
(
tableName
,
attrValueHash
,
where
)
{
...
...
lib/dialects/postgres/query.js
View file @
d2e9adc
...
@@ -118,6 +118,7 @@ module.exports = (function() {
...
@@ -118,6 +118,7 @@ module.exports = (function() {
this
.
callee
[
key
]
=
record
this
.
callee
[
key
]
=
record
}
}
}
}
}
this
.
emit
(
'success'
,
this
.
callee
)
this
.
emit
(
'success'
,
this
.
callee
)
}
else
if
(
this
.
send
(
'isUpdateQuery'
))
{
}
else
if
(
this
.
send
(
'isUpdateQuery'
))
{
...
@@ -131,6 +132,7 @@ module.exports = (function() {
...
@@ -131,6 +132,7 @@ module.exports = (function() {
this
.
callee
[
key
]
=
record
this
.
callee
[
key
]
=
record
}
}
}
}
}
this
.
emit
(
'success'
,
this
.
callee
)
this
.
emit
(
'success'
,
this
.
callee
)
}
else
{
}
else
{
...
...
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