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 624e89f9
authored
Mar 28, 2014
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new log method
1 parent
8d02f36b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
35 deletions
lib/dialects/mariadb/query.js
lib/dialects/mysql/query.js
lib/dialects/postgres/query.js
lib/dialects/sqlite/query.js
lib/migrator.js
lib/dialects/mariadb/query.js
View file @
624e89f
...
@@ -19,9 +19,7 @@ module.exports = (function() {
...
@@ -19,9 +19,7 @@ module.exports = (function() {
Query
.
prototype
.
run
=
function
(
sql
)
{
Query
.
prototype
.
run
=
function
(
sql
)
{
this
.
sql
=
sql
this
.
sql
=
sql
if
(
this
.
options
.
logging
!==
false
)
{
this
.
sequelize
.
log
(
'Executing ('
+
this
.
options
.
uuid
+
'): '
+
this
.
sql
)
this
.
options
.
logging
(
'Executing ('
+
this
.
options
.
uuid
+
'): '
+
this
.
sql
)
}
var
resultSet
=
[],
var
resultSet
=
[],
errorDetected
=
false
,
errorDetected
=
false
,
...
...
lib/dialects/mysql/query.js
View file @
624e89f
...
@@ -19,9 +19,7 @@ module.exports = (function() {
...
@@ -19,9 +19,7 @@ module.exports = (function() {
Query
.
prototype
.
run
=
function
(
sql
)
{
Query
.
prototype
.
run
=
function
(
sql
)
{
this
.
sql
=
sql
this
.
sql
=
sql
if
(
this
.
options
.
logging
!==
false
)
{
this
.
sequelize
.
log
(
'Executing ('
+
this
.
options
.
uuid
+
'): '
+
this
.
sql
)
this
.
options
.
logging
(
'Executing ('
+
this
.
options
.
uuid
+
'): '
+
this
.
sql
)
}
this
.
client
.
query
(
this
.
sql
,
function
(
err
,
results
,
fields
)
{
this
.
client
.
query
(
this
.
sql
,
function
(
err
,
results
,
fields
)
{
this
.
emit
(
'sql'
,
this
.
sql
)
this
.
emit
(
'sql'
,
this
.
sql
)
...
...
lib/dialects/postgres/query.js
View file @
624e89f
...
@@ -27,9 +27,7 @@ module.exports = (function() {
...
@@ -27,9 +27,7 @@ module.exports = (function() {
,
query
=
this
.
client
.
query
(
sql
)
,
query
=
this
.
client
.
query
(
sql
)
,
rows
=
[]
,
rows
=
[]
if
(
this
.
options
.
logging
!==
false
)
{
this
.
sequelize
.
log
(
'Executing ('
+
this
.
options
.
uuid
+
'): '
+
this
.
sql
)
this
.
options
.
logging
(
'Executing ('
+
this
.
options
.
uuid
+
'): '
+
this
.
sql
)
}
query
.
on
(
'row'
,
function
(
row
)
{
query
.
on
(
'row'
,
function
(
row
)
{
rows
.
push
(
row
)
rows
.
push
(
row
)
...
@@ -143,8 +141,8 @@ module.exports = (function() {
...
@@ -143,8 +141,8 @@ module.exports = (function() {
this
.
callee
.
dataValues
[
key
]
=
record
this
.
callee
.
dataValues
[
key
]
=
record
}
}
}
}
}
}
this
.
emit
(
'success'
,
this
.
callee
)
this
.
emit
(
'success'
,
this
.
callee
)
}
else
if
([
QueryTypes
.
BULKUPDATE
,
QueryTypes
.
BULKDELETE
].
indexOf
(
this
.
options
.
type
)
!==
-
1
)
{
}
else
if
([
QueryTypes
.
BULKUPDATE
,
QueryTypes
.
BULKDELETE
].
indexOf
(
this
.
options
.
type
)
!==
-
1
)
{
this
.
emit
(
'success'
,
result
.
rowCount
)
this
.
emit
(
'success'
,
result
.
rowCount
)
}
else
if
(
this
.
send
(
'isUpdateQuery'
))
{
}
else
if
(
this
.
send
(
'isUpdateQuery'
))
{
...
...
lib/dialects/sqlite/query.js
View file @
624e89f
...
@@ -26,9 +26,7 @@ module.exports = (function() {
...
@@ -26,9 +26,7 @@ module.exports = (function() {
this
.
sql
=
sql
this
.
sql
=
sql
if
(
this
.
options
.
logging
!==
false
)
{
this
.
sequelize
.
log
(
'Executing ('
+
this
.
options
.
uuid
+
'): '
+
this
.
sql
)
this
.
options
.
logging
(
'Executing ('
+
this
.
options
.
uuid
+
'): '
+
this
.
sql
)
}
var
columnTypes
=
{}
var
columnTypes
=
{}
this
.
database
.
serialize
(
function
()
{
this
.
database
.
serialize
(
function
()
{
...
@@ -67,7 +65,7 @@ module.exports = (function() {
...
@@ -67,7 +65,7 @@ module.exports = (function() {
executeSql
()
executeSql
()
}
else
{
}
else
{
var
execute
=
Utils
.
_
.
after
(
tableNames
.
length
,
executeSql
)
var
execute
=
Utils
.
_
.
after
(
tableNames
.
length
,
executeSql
)
tableNames
.
forEach
(
function
(
tableName
)
{
tableNames
.
forEach
(
function
(
tableName
)
{
if
(
tableName
!==
'sqlite_master'
)
{
if
(
tableName
!==
'sqlite_master'
)
{
// get the column types
// get the column types
...
@@ -174,7 +172,7 @@ module.exports = (function() {
...
@@ -174,7 +172,7 @@ module.exports = (function() {
}
else
if
(
this
.
sql
.
indexOf
(
'PRAGMA foreign_keys'
)
!==
-
1
)
{
}
else
if
(
this
.
sql
.
indexOf
(
'PRAGMA foreign_keys'
)
!==
-
1
)
{
result
=
results
result
=
results
}
else
if
([
QueryTypes
.
BULKUPDATE
,
QueryTypes
.
BULKDELETE
].
indexOf
(
this
.
options
.
type
)
!==
-
1
)
{
}
else
if
([
QueryTypes
.
BULKUPDATE
,
QueryTypes
.
BULKDELETE
].
indexOf
(
this
.
options
.
type
)
!==
-
1
)
{
result
=
metaData
.
changes
result
=
metaData
.
changes
}
}
this
.
emit
(
'success'
,
result
)
this
.
emit
(
'success'
,
result
)
...
...
lib/migrator.js
View file @
624e89f
...
@@ -15,16 +15,6 @@ module.exports = (function() {
...
@@ -15,16 +15,6 @@ module.exports = (function() {
logging
:
console
.
log
,
logging
:
console
.
log
,
filesFilter
:
/
\.
js$/
filesFilter
:
/
\.
js$/
},
options
||
{})
},
options
||
{})
if
(
this
.
options
.
logging
===
true
)
{
console
.
log
(
'DEPRECATION WARNING: The logging-option should be either a function or false. Default: console.log'
)
this
.
options
.
logging
=
console
.
log
}
if
(
this
.
options
.
logging
==
console
.
log
)
{
// using just console.log will break in node < 0.6
this
.
options
.
logging
=
function
(
s
)
{
console
.
log
(
s
)
}
}
}
}
Object
.
defineProperty
(
Migrator
.
prototype
,
"queryInterface"
,
{
Object
.
defineProperty
(
Migrator
.
prototype
,
"queryInterface"
,
{
...
@@ -53,9 +43,9 @@ module.exports = (function() {
...
@@ -53,9 +43,9 @@ module.exports = (function() {
}
}
if
(
migrations
.
length
===
0
)
{
if
(
migrations
.
length
===
0
)
{
self
.
options
.
loggin
g
(
"There are no pending migrations."
)
self
.
sequelize
.
lo
g
(
"There are no pending migrations."
)
}
else
{
}
else
{
self
.
options
.
loggin
g
(
"Running migrations..."
)
self
.
sequelize
.
lo
g
(
"Running migrations..."
)
}
}
migrations
.
forEach
(
function
(
migration
)
{
migrations
.
forEach
(
function
(
migration
)
{
...
@@ -63,9 +53,7 @@ module.exports = (function() {
...
@@ -63,9 +53,7 @@ module.exports = (function() {
chainer
.
add
(
migration
,
'execute'
,
[
options
],
{
chainer
.
add
(
migration
,
'execute'
,
[
options
],
{
before
:
function
(
migration
)
{
before
:
function
(
migration
)
{
if
(
self
.
options
.
logging
!==
false
)
{
self
.
sequelize
.
log
(
migration
.
filename
)
self
.
options
.
logging
(
migration
.
filename
)
}
migrationTime
=
process
.
hrtime
()
migrationTime
=
process
.
hrtime
()
},
},
...
@@ -73,9 +61,7 @@ module.exports = (function() {
...
@@ -73,9 +61,7 @@ module.exports = (function() {
migrationTime
=
process
.
hrtime
(
migrationTime
)
migrationTime
=
process
.
hrtime
(
migrationTime
)
migrationTime
=
Math
.
round
(
(
migrationTime
[
0
]
*
1000
)
+
(
migrationTime
[
1
]
/
1000000
));
migrationTime
=
Math
.
round
(
(
migrationTime
[
0
]
*
1000
)
+
(
migrationTime
[
1
]
/
1000000
));
if
(
self
.
options
.
logging
!==
false
)
{
self
.
sequelize
.
log
(
'Completed in '
+
migrationTime
+
'ms'
)
self
.
options
.
logging
(
'Completed in '
+
migrationTime
+
'ms'
)
}
},
},
success
:
function
(
migration
,
callback
)
{
success
:
function
(
migration
,
callback
)
{
...
@@ -193,8 +179,10 @@ module.exports = (function() {
...
@@ -193,8 +179,10 @@ module.exports = (function() {
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
var
chainer
=
new
Utils
.
QueryChainer
()
var
chainer
=
new
Utils
.
QueryChainer
()
var
addMigration
=
function
(
filename
)
{
var
addMigration
=
function
(
filename
)
{
self
.
options
.
logging
(
'Adding migration script at '
+
filename
)
var
migration
=
new
Migration
(
self
,
filename
)
var
migration
=
new
Migration
(
self
,
filename
)
self
.
sequelize
.
log
(
'Adding migration script at '
+
filename
)
chainer
.
add
(
migration
,
'execute'
,
[{
method
:
'up'
}],
{
chainer
.
add
(
migration
,
'execute'
,
[{
method
:
'up'
}],
{
before
:
function
(
migration
)
{
before
:
function
(
migration
)
{
if
(
options
&&
Utils
.
_
.
isFunction
(
options
.
before
))
{
if
(
options
&&
Utils
.
_
.
isFunction
(
options
.
before
))
{
...
...
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