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 99d83343
authored
Dec 14, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sqlite extends mysql now
1 parent
7c3df785
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
55 deletions
lib/connectors/sqlite/query-generator.js
lib/connectors/sqlite/query-generator.js
View file @
99d8334
...
@@ -25,64 +25,10 @@ module.exports = (function() {
...
@@ -25,64 +25,10 @@ module.exports = (function() {
return
Utils
.
_
.
template
(
query
)(
values
).
trim
()
+
";"
return
Utils
.
_
.
template
(
query
)(
values
).
trim
()
+
";"
},
},
dropTableQuery
:
function
(
tableName
,
options
)
{
options
=
options
||
{}
var
query
=
"DROP TABLE IF EXISTS <%= table %>;"
return
Utils
.
_
.
template
(
query
)({
table
:
Utils
.
addTicks
(
tableName
)})
},
showTablesQuery
:
function
()
{
showTablesQuery
:
function
()
{
return
"SELECT name FROM sqlite_master WHERE type='table';"
return
"SELECT name FROM sqlite_master WHERE type='table';"
},
},
selectQuery
:
function
(
tableName
,
options
)
{
options
=
options
||
{}
options
.
table
=
Utils
.
addTicks
(
tableName
)
options
.
attributes
=
options
.
attributes
&&
options
.
attributes
.
map
(
function
(
attr
){
if
(
Array
.
isArray
(
attr
)
&&
attr
.
length
==
2
)
return
[
attr
[
0
],
Utils
.
addTicks
(
attr
[
1
])].
join
(
' as '
)
else
return
Utils
.
addTicks
(
attr
)
}).
join
(
", "
)
options
.
attributes
=
options
.
attributes
||
'*'
var
query
=
"SELECT <%= attributes %> FROM <%= table %>"
if
(
options
.
where
)
{
options
.
where
=
QueryGenerator
.
getWhereConditions
(
options
.
where
)
query
+=
" WHERE <%= where %>"
}
if
(
options
.
order
)
query
+=
" ORDER BY <%= order %>"
if
(
options
.
group
)
{
options
.
group
=
Utils
.
addTicks
(
options
.
group
)
query
+=
" GROUP BY <%= group %>"
}
if
(
options
.
limit
)
{
if
(
options
.
offset
)
query
+=
" LIMIT <%= offset %>, <%= limit %>"
else
query
+=
" LIMIT <%= limit %>"
}
query
+=
";"
return
Utils
.
_
.
template
(
query
)(
options
)
},
insertQuery
:
function
(
tableName
,
attrValueHash
)
{
var
query
=
"INSERT INTO <%= table %> (<%= attributes %>) VALUES (<%= values %>);"
var
replacements
=
{
table
:
Utils
.
addTicks
(
tableName
),
attributes
:
Utils
.
_
.
keys
(
attrValueHash
).
map
(
function
(
attr
){
return
Utils
.
addTicks
(
attr
)}).
join
(
","
),
values
:
Utils
.
_
.
values
(
attrValueHash
).
map
(
function
(
value
){
return
Utils
.
escape
((
value
instanceof
Date
)
?
Utils
.
toSqlDate
(
value
)
:
value
)
}).
join
(
","
)
}
return
Utils
.
_
.
template
(
query
)(
replacements
)
},
attributesToSQL
:
function
(
attributes
)
{
attributesToSQL
:
function
(
attributes
)
{
var
result
=
{}
var
result
=
{}
...
@@ -112,5 +58,10 @@ module.exports = (function() {
...
@@ -112,5 +58,10 @@ module.exports = (function() {
}
}
}
}
return
Utils
.
_
.
extend
(
Utils
.
_
.
clone
(
require
(
"../query-generator"
)),
QueryGenerator
)
var
MySqlQueryGenerator
=
Utils
.
_
.
extend
(
Utils
.
_
.
clone
(
require
(
"../query-generator"
)),
Utils
.
_
.
clone
(
require
(
"../mysql/query-generator"
))
)
return
Utils
.
_
.
extend
(
MySqlQueryGenerator
,
QueryGenerator
)
})()
})()
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