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 3d71f043
authored
Jan 04, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just ONE type of incrementQuery
1 parent
0e82a72a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
82 deletions
lib/dialects/abstract/query-generator.js
lib/dialects/mysql/query-generator.js
lib/dialects/postgres/query-generator.js
lib/dialects/sqlite/query-generator.js
lib/dialects/abstract/query-generator.js
View file @
3d71f04
...
@@ -190,8 +190,35 @@ module.exports = (function() {
...
@@ -190,8 +190,35 @@ module.exports = (function() {
OR a string with conditions (e.g. 'name="foo"').
OR a string with conditions (e.g. 'name="foo"').
If you use a string, you have to escape it on your own.
If you use a string, you have to escape it on your own.
*/
*/
incrementQuery
:
function
(
tableName
,
values
,
where
)
{
incrementQuery
:
function
(
tableName
,
attrValueHash
,
where
,
options
)
{
throwMethodUndefined
(
'incrementQuery'
)
attrValueHash
=
Utils
.
removeNullValuesFromHash
(
attrValueHash
,
this
.
options
.
omitNull
)
var
query
,
values
=
[]
query
=
"UPDATE <%= table %> SET <%= values %> WHERE <%= where %>"
if
(
this
.
_dialect
.
supports
[
'RETURNING'
])
{
query
+=
" RETURNING *"
}
for
(
var
key
in
attrValueHash
)
{
var
value
=
attrValueHash
[
key
]
values
.
push
(
this
.
quoteIdentifier
(
key
)
+
"="
+
this
.
quoteIdentifier
(
key
)
+
" + "
+
this
.
escape
(
value
))
}
options
=
options
||
{}
for
(
var
key
in
options
)
{
var
value
=
options
[
key
];
values
.
push
(
this
.
quoteIdentifier
(
key
)
+
"="
+
this
.
escape
(
value
))
}
var
replacements
=
{
table
:
this
.
quoteIdentifiers
(
tableName
),
values
:
values
.
join
(
","
),
where
:
this
.
getWhereConditions
(
where
)
}
return
Utils
.
_
.
template
(
query
)(
replacements
)
},
},
/*
/*
...
...
lib/dialects/mysql/query-generator.js
View file @
3d71f04
...
@@ -238,33 +238,6 @@ module.exports = (function() {
...
@@ -238,33 +238,6 @@ module.exports = (function() {
return
query
return
query
},
},
incrementQuery
:
function
(
tableName
,
attrValueHash
,
where
,
options
)
{
attrValueHash
=
Utils
.
removeNullValuesFromHash
(
attrValueHash
,
this
.
options
.
omitNull
)
var
values
=
[]
for
(
var
key
in
attrValueHash
)
{
var
value
=
attrValueHash
[
key
]
,
_value
=
this
.
escape
(
value
)
values
.
push
(
this
.
quoteIdentifier
(
key
)
+
"="
+
this
.
quoteIdentifier
(
key
)
+
" + "
+
_value
)
}
options
=
options
||
{}
for
(
var
key
in
options
)
{
var
value
=
options
[
key
];
values
.
push
(
this
.
quoteIdentifier
(
key
)
+
"="
+
this
.
escape
(
value
))
}
var
table
=
this
.
quoteIdentifier
(
tableName
)
values
=
values
.
join
(
","
)
where
=
this
.
getWhereConditions
(
where
)
var
query
=
"UPDATE "
+
table
+
" SET "
+
values
+
" WHERE "
+
where
return
query
},
addIndexQuery
:
function
(
tableName
,
attributes
,
options
)
{
addIndexQuery
:
function
(
tableName
,
attributes
,
options
)
{
var
transformedAttributes
=
attributes
.
map
(
function
(
attribute
)
{
var
transformedAttributes
=
attributes
.
map
(
function
(
attribute
)
{
if
(
typeof
attribute
===
'string'
)
{
if
(
typeof
attribute
===
'string'
)
{
...
...
lib/dialects/postgres/query-generator.js
View file @
3d71f04
...
@@ -371,33 +371,6 @@ module.exports = (function() {
...
@@ -371,33 +371,6 @@ module.exports = (function() {
return
Utils
.
_
.
template
(
query
)(
replacements
)
return
Utils
.
_
.
template
(
query
)(
replacements
)
},
},
incrementQuery
:
function
(
tableName
,
attrValueHash
,
where
,
options
)
{
attrValueHash
=
Utils
.
removeNullValuesFromHash
(
attrValueHash
,
this
.
options
.
omitNull
)
var
query
=
"UPDATE <%= table %> SET <%= values %> WHERE <%= where %> RETURNING *"
,
values
=
[]
for
(
var
key
in
attrValueHash
)
{
var
value
=
attrValueHash
[
key
]
values
.
push
(
this
.
quoteIdentifier
(
key
)
+
"="
+
this
.
quoteIdentifier
(
key
)
+
" + "
+
this
.
escape
(
value
))
}
options
=
options
||
{}
for
(
var
key
in
options
)
{
var
value
=
options
[
key
];
values
.
push
(
this
.
quoteIdentifier
(
key
)
+
"="
+
this
.
escape
(
value
))
}
var
replacements
=
{
table
:
this
.
quoteIdentifiers
(
tableName
),
values
:
values
.
join
(
","
),
where
:
this
.
getWhereConditions
(
where
)
}
return
Utils
.
_
.
template
(
query
)(
replacements
)
},
addIndexQuery
:
function
(
tableName
,
attributes
,
options
)
{
addIndexQuery
:
function
(
tableName
,
attributes
,
options
)
{
var
transformedAttributes
=
attributes
.
map
(
function
(
attribute
)
{
var
transformedAttributes
=
attributes
.
map
(
function
(
attribute
)
{
if
(
typeof
attribute
===
'string'
)
{
if
(
typeof
attribute
===
'string'
)
{
...
...
lib/dialects/sqlite/query-generator.js
View file @
3d71f04
...
@@ -214,32 +214,6 @@ module.exports = (function() {
...
@@ -214,32 +214,6 @@ module.exports = (function() {
return
Utils
.
_
.
template
(
query
)(
replacements
)
return
Utils
.
_
.
template
(
query
)(
replacements
)
},
},
incrementQuery
:
function
(
tableName
,
attrValueHash
,
where
,
options
)
{
attrValueHash
=
Utils
.
removeNullValuesFromHash
(
attrValueHash
,
this
.
options
.
omitNull
)
var
query
=
"UPDATE <%= table %> SET <%= values %> WHERE <%= where %>"
,
values
=
[]
for
(
var
key
in
attrValueHash
)
{
var
value
=
attrValueHash
[
key
]
values
.
push
(
this
.
quoteIdentifier
(
key
)
+
"="
+
this
.
quoteIdentifier
(
key
)
+
"+ "
+
this
.
escape
(
value
))
}
options
=
options
||
{}
for
(
var
key
in
options
)
{
var
value
=
options
[
key
];
values
.
push
(
this
.
quoteIdentifier
(
key
)
+
"="
+
this
.
escape
(
value
))
}
var
replacements
=
{
table
:
this
.
quoteIdentifier
(
tableName
),
values
:
values
.
join
(
","
),
where
:
this
.
getWhereConditions
(
where
)
}
return
Utils
.
_
.
template
(
query
)(
replacements
)
},
attributesToSQL
:
function
(
attributes
)
{
attributesToSQL
:
function
(
attributes
)
{
var
result
=
{}
var
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