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 c5c1ea6d
authored
Sep 01, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor formatting
1 parent
cd13012d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
lib/dao-factory.js
lib/dialects/mysql/query-generator.js
lib/dao-factory.js
View file @
c5c1ea6
...
@@ -109,9 +109,9 @@ module.exports = (function() {
...
@@ -109,9 +109,9 @@ module.exports = (function() {
}
}
// options is not a hash but an id
// options is not a hash but an id
if
(
typeof
options
==
'number'
)
if
(
typeof
options
==
=
'number'
)
{
options
=
{
where
:
options
}
options
=
{
where
:
options
}
else
if
(
Utils
.
argsArePrimaryKeys
(
arguments
,
this
.
primaryKeys
))
{
}
else
if
(
Utils
.
argsArePrimaryKeys
(
arguments
,
this
.
primaryKeys
))
{
var
where
=
{}
var
where
=
{}
,
self
=
this
,
self
=
this
...
@@ -125,7 +125,7 @@ module.exports = (function() {
...
@@ -125,7 +125,7 @@ module.exports = (function() {
options
.
limit
=
1
options
.
limit
=
1
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
plain
:
true
})
return
this
.
QueryInterface
.
select
(
this
,
this
.
tableName
,
options
,
{
plain
:
true
})
}
}
DAOFactory
.
prototype
.
count
=
function
(
options
)
{
DAOFactory
.
prototype
.
count
=
function
(
options
)
{
...
...
lib/dialects/mysql/query-generator.js
View file @
c5c1ea6
...
@@ -111,11 +111,16 @@ module.exports = (function() {
...
@@ -111,11 +111,16 @@ module.exports = (function() {
options
.
where
=
QueryGenerator
.
getWhereConditions
(
options
.
where
)
options
.
where
=
QueryGenerator
.
getWhereConditions
(
options
.
where
)
query
+=
" WHERE <%= where %>"
query
+=
" WHERE <%= where %>"
}
}
if
(
options
.
order
)
query
+=
" ORDER BY <%= order %>"
if
(
options
.
order
)
{
query
+=
" ORDER BY <%= order %>"
}
if
(
options
.
group
)
{
if
(
options
.
group
)
{
options
.
group
=
Utils
.
addTicks
(
options
.
group
)
options
.
group
=
Utils
.
addTicks
(
options
.
group
)
query
+=
" GROUP BY <%= group %>"
query
+=
" GROUP BY <%= group %>"
}
}
if
(
options
.
limit
)
{
if
(
options
.
limit
)
{
if
(
options
.
offset
)
query
+=
" LIMIT <%= offset %>, <%= limit %>"
if
(
options
.
offset
)
query
+=
" LIMIT <%= offset %>, <%= limit %>"
else
query
+=
" LIMIT <%= limit %>"
else
query
+=
" LIMIT <%= limit %>"
...
@@ -233,14 +238,15 @@ module.exports = (function() {
...
@@ -233,14 +238,15 @@ module.exports = (function() {
getWhereConditions
:
function
(
smth
)
{
getWhereConditions
:
function
(
smth
)
{
var
result
=
null
var
result
=
null
if
(
Utils
.
isHash
(
smth
))
if
(
Utils
.
isHash
(
smth
))
{
result
=
QueryGenerator
.
hashToWhereConditions
(
smth
)
result
=
QueryGenerator
.
hashToWhereConditions
(
smth
)
else
if
(
typeof
smth
==
'number'
)
}
else
if
(
typeof
smth
===
'number'
)
{
result
=
Utils
.
addTicks
(
'id'
)
+
"="
+
Utils
.
escape
(
smth
)
result
=
Utils
.
addTicks
(
'id'
)
+
"="
+
Utils
.
escape
(
smth
)
else
if
(
typeof
smth
==
"string"
)
}
else
if
(
typeof
smth
===
"string"
)
{
result
=
smth
result
=
smth
else
if
(
Array
.
isArray
(
smth
))
}
else
if
(
Array
.
isArray
(
smth
))
{
result
=
Utils
.
format
(
smth
)
result
=
Utils
.
format
(
smth
)
}
return
result
return
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