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 b1f106ca
authored
Jan 22, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(sql/where): move more cases to whereQuery
1 parent
b5f7153c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
6 deletions
lib/dialects/abstract/query-generator.js
test/integration/dialects/mysql/query-generator.test.js
test/integration/dialects/sqlite/query-generator.test.js
test/unit/sql/where.test.js
lib/dialects/abstract/query-generator.js
View file @
b1f106c
...
...
@@ -1630,6 +1630,8 @@ module.exports = (function() {
if
(
value
instanceof
Utils
.
or
||
value
instanceof
Utils
.
and
)
{
key
=
value
instanceof
Utils
.
or
?
"$or"
:
"$and"
;
value
=
value
.
args
;
}
else
if
(
typeof
value
===
"string"
)
{
return
value
;
}
}
...
...
@@ -1766,7 +1768,10 @@ module.exports = (function() {
prefix
:
prepend
&&
tableName
});
}
else
if
(
typeof
smth
===
'string'
)
{
result
=
smth
;
return
self
.
whereItemsQuery
(
smth
,
{
model
:
factory
,
prefix
:
prepend
&&
tableName
});
}
else
if
(
Buffer
.
isBuffer
(
smth
))
{
result
=
this
.
escape
(
smth
);
}
else
if
(
Array
.
isArray
(
smth
))
{
...
...
@@ -1779,7 +1784,10 @@ module.exports = (function() {
result
=
Utils
.
format
(
smth
,
this
.
dialect
);
}
}
else
if
(
smth
===
null
)
{
result
=
'1=1'
;
return
self
.
whereItemsQuery
(
smth
,
{
model
:
factory
,
prefix
:
prepend
&&
tableName
});
}
return
result
?
result
:
'1=1'
;
...
...
test/integration/dialects/mysql/query-generator.test.js
View file @
b1f106c
...
...
@@ -316,12 +316,12 @@ if (Support.dialectIsMySQL()) {
},
{
title
:
'no where arguments (string)'
,
arguments
:
[
'myTable'
,
{
where
:
''
}],
expectation
:
'SELECT * FROM `myTable`
WHERE 1=1
;'
,
expectation
:
'SELECT * FROM `myTable`;'
,
context
:
QueryGenerator
},
{
title
:
'no where arguments (null)'
,
arguments
:
[
'myTable'
,
{
where
:
null
}],
expectation
:
'SELECT * FROM `myTable`
WHERE 1=1
;'
,
expectation
:
'SELECT * FROM `myTable`;'
,
context
:
QueryGenerator
},
{
title
:
'buffer as where argument'
,
...
...
test/integration/dialects/sqlite/query-generator.test.js
View file @
b1f106c
...
...
@@ -299,12 +299,12 @@ if (dialect === 'sqlite') {
},
{
title
:
'no where arguments (string)'
,
arguments
:
[
'myTable'
,
{
where
:
''
}],
expectation
:
'SELECT * FROM `myTable`
WHERE 1=1
;'
,
expectation
:
'SELECT * FROM `myTable`;'
,
context
:
QueryGenerator
},
{
title
:
'no where arguments (null)'
,
arguments
:
[
'myTable'
,
{
where
:
null
}],
expectation
:
'SELECT * FROM `myTable`
WHERE 1=1
;'
,
expectation
:
'SELECT * FROM `myTable`;'
,
context
:
QueryGenerator
},
{
title
:
'buffer as where argument'
,
...
...
test/unit/sql/where.test.js
View file @
b1f106c
...
...
@@ -78,6 +78,10 @@ suite('SQL', function() {
});
};
testsql
(
undefined
,
'lol=1'
,
{
default
:
"lol=1"
});
testsql
(
'deleted'
,
null
,
{
default
:
"`deleted` IS NULL"
,
postgres
:
'"deleted" IS NULL'
,
...
...
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