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 7197c034
authored
Oct 24, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sqlite
1 parent
49c07dca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
10 deletions
lib/dialects/sqlite/query-generator.js
lib/dialects/sqlite/query.js
lib/dialects/sqlite/query-generator.js
View file @
7197c03
var
Utils
=
require
(
"../../utils"
)
,
DataTypes
=
require
(
"../../data-types"
)
,
SqlString
=
require
(
"../../sql-string"
)
var
Utils
=
require
(
"../../utils"
)
,
DataTypes
=
require
(
"../../data-types"
)
,
SqlString
=
require
(
"../../sql-string"
)
,
Transaction
=
require
(
"../../transaction"
)
var
MySqlQueryGenerator
=
Utils
.
_
.
extend
(
Utils
.
_
.
clone
(
require
(
"../abstract/query-generator"
)),
...
...
@@ -396,6 +397,29 @@ module.exports = (function() {
})
},
startTransactionQuery
:
function
(
options
)
{
return
"BEGIN TRANSACTION;"
},
setAutocommitQuery
:
function
(
value
)
{
return
"-- SQLite does not support SET autocommit."
},
setIsolationLevelQuery
:
function
(
value
)
{
switch
(
value
)
{
case
Transaction
.
ISOLATION_LEVELS
.
REPEATABLE_READ
:
return
"-- SQLite is not able to choose the isolation level REPEATABLE READ."
case
Transaction
.
ISOLATION_LEVELS
.
READ_UNCOMMITTED
:
return
"PRAGMA read_uncommitted = ON;"
case
Transaction
.
ISOLATION_LEVELS
.
READ_COMMITTED
:
return
"PRAGMA read_uncommitted = OFF;"
case
Transaction
.
ISOLATION_LEVELS
.
SERIALIZABLE
:
return
"-- SQLite's default isolation level is SERIALIZABLE. Nothing to do."
default
:
throw
new
Error
(
'Unknown isolation level: '
+
value
)
}
},
replaceBooleanDefaults
:
function
(
sql
)
{
return
sql
.
replace
(
/DEFAULT '
?
false'
?
/g
,
"DEFAULT 0"
).
replace
(
/DEFAULT '
?
true'
?
/g
,
"DEFAULT 1"
)
},
...
...
lib/dialects/sqlite/query.js
View file @
7197c03
...
...
@@ -32,13 +32,22 @@ module.exports = (function() {
var
columnTypes
=
{}
this
.
database
.
serialize
(
function
()
{
var
executeSql
=
function
()
{
self
.
database
[
getDatabaseMethod
.
call
(
self
)](
self
.
sql
,
function
(
err
,
results
)
{
// allow clients to listen to sql to do their own logging or whatnot
self
.
emit
(
'sql'
,
self
.
sql
)
this
.
columnTypes
=
columnTypes
;
err
?
onFailure
.
call
(
self
,
err
)
:
onSuccess
.
call
(
self
,
results
,
this
)
})
};
if
(
self
.
sql
.
indexOf
(
'-- '
)
===
0
)
{
// the sql query starts with a comment. don't bother the server with that ...
Utils
.
tick
(
function
()
{
self
.
emit
(
'sql'
,
self
.
sql
)
console
.
log
(
'emitting success'
)
self
.
emit
(
'success'
,
null
)
})
}
else
{
self
.
database
[
getDatabaseMethod
.
call
(
self
)](
self
.
sql
,
function
(
err
,
results
)
{
// allow clients to listen to sql to do their own logging or whatnot
self
.
emit
(
'sql'
,
self
.
sql
)
this
.
columnTypes
=
columnTypes
;
err
?
onFailure
.
call
(
self
,
err
)
:
onSuccess
.
call
(
self
,
results
,
this
)
})
}
}
if
((
getDatabaseMethod
.
call
(
self
)
===
'all'
)
&&
/select
\s
.*
?\s
from
\s
+
([^
;
]
+
)
/i
.
test
(
self
.
sql
))
{
var
tableName
=
RegExp
.
$1
;
...
...
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