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 b8d05967
authored
Apr 28, 2012
by
Nao Iizuka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decode DATETIME to Date object in sqlite
1 parent
f680021a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
4 deletions
lib/dialects/sqlite/query.js
lib/dialects/sqlite/query.js
View file @
b8d0596
...
...
@@ -20,16 +20,38 @@ module.exports = (function() {
if
(
this
.
options
.
logging
!==
false
)
this
.
options
.
logging
(
'Executing: '
+
this
.
sql
)
var
columnTypes
=
{};
this
.
database
.
serialize
(
function
()
{
var
isInsertCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'insert'
)
==
0
)
,
isUpdateCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'update'
)
==
0
)
,
databaseMethod
=
(
isInsertCommand
||
isUpdateCommand
)
?
'run'
:
'all'
var
executeSql
=
function
()
{
self
.
database
[
databaseMethod
](
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
)
})
};
var
isInsertCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'insert'
)
==
0
)
,
isUpdateCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'update'
)
==
0
)
,
databaseMethod
=
(
isInsertCommand
||
isUpdateCommand
)
?
'run'
:
'all'
if
(
databaseMethod
===
'all'
&&
/select
\s
.*
?\s
from
\s
+
([^
;
]
+
)
/i
.
test
(
self
.
sql
))
{
var
tableName
=
RegExp
.
$1
;
if
(
tableName
!==
'sqlite_master'
)
{
// get the column types
self
.
database
.
all
(
"PRAGMA table_info("
+
tableName
+
")"
,
function
(
err
,
results
)
{
if
(
!
err
)
{
for
(
var
i
=
0
,
l
=
results
.
length
;
i
<
l
;
i
++
)
{
columnTypes
[
results
[
i
].
name
]
=
results
[
i
].
type
;
}
}
executeSql
();
});
}
else
{
executeSql
();
}
}
else
{
executeSql
();
}
})
return
this
...
...
@@ -57,6 +79,11 @@ module.exports = (function() {
result
=
results
}
else
{
result
=
results
.
map
(
function
(
result
)
{
for
(
var
name
in
result
)
{
if
(
metaData
.
columnTypes
[
name
]
===
'DATETIME'
)
{
result
[
name
]
=
new
Date
(
result
[
name
]);
}
}
return
self
.
callee
.
build
(
result
,
{
isNewRecord
:
false
})
})
}
...
...
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