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 a35ed080
authored
Oct 07, 2012
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added function for the check of the logging option
1 parent
0fd1a934
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
34 deletions
lib/dialects/abstract/query.js
lib/dialects/mysql/query.js
lib/dialects/postgres/query.js
lib/dialects/sqlite/query.js
lib/dialects/abstract/query.js
View file @
a35ed08
...
@@ -2,9 +2,7 @@ var Utils = require('../../utils')
...
@@ -2,9 +2,7 @@ var Utils = require('../../utils')
,
CustomEventEmitter
=
require
(
"../../emitters/custom-event-emitter"
)
,
CustomEventEmitter
=
require
(
"../../emitters/custom-event-emitter"
)
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
AbstractQuery
=
function
(
database
,
sequelize
,
callee
,
options
)
{
var
AbstractQuery
=
function
(
database
,
sequelize
,
callee
,
options
)
{}
}
/**
/**
Inherit from CustomEventEmitter
Inherit from CustomEventEmitter
...
@@ -26,6 +24,23 @@ module.exports = (function() {
...
@@ -26,6 +24,23 @@ module.exports = (function() {
}
}
/**
/**
* Check the logging option of the instance and print deprecation warnings.
*
* @return {void}
*/
AbstractQuery
.
prototype
.
checkLoggingOption
=
function
()
{
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
)
}
}
}
/**
* High level function that handles the results of a query execution.
* High level function that handles the results of a query execution.
*
*
*
*
...
@@ -101,6 +116,10 @@ module.exports = (function() {
...
@@ -101,6 +116,10 @@ module.exports = (function() {
return
this
return
this
}
}
/////////////
// private //
/////////////
var
queryResultHasJoin
=
function
(
results
)
{
var
queryResultHasJoin
=
function
(
results
)
{
var
hasJoin
=
!!
results
[
0
]
var
hasJoin
=
!!
results
[
0
]
...
...
lib/dialects/mysql/query.js
View file @
a35ed08
...
@@ -14,16 +14,7 @@ module.exports = (function() {
...
@@ -14,16 +14,7 @@ module.exports = (function() {
raw
:
false
raw
:
false
},
options
||
{})
},
options
||
{})
if
(
this
.
options
.
logging
===
true
)
{
this
.
checkLoggingOption
()
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
)
}
}
this
.
bindClientFunction
=
function
(
err
)
{
onFailure
.
call
(
self
,
err
)
}
this
.
bindClientFunction
=
function
(
err
)
{
onFailure
.
call
(
self
,
err
)
}
}
}
...
...
lib/dialects/postgres/query.js
View file @
a35ed08
...
@@ -3,8 +3,6 @@ var Utils = require("../../utils")
...
@@ -3,8 +3,6 @@ var Utils = require("../../utils")
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
Query
=
function
(
client
,
sequelize
,
callee
,
options
)
{
var
Query
=
function
(
client
,
sequelize
,
callee
,
options
)
{
var
self
=
this
this
.
client
=
client
this
.
client
=
client
this
.
sequelize
=
sequelize
this
.
sequelize
=
sequelize
this
.
callee
=
callee
this
.
callee
=
callee
...
@@ -14,15 +12,7 @@ module.exports = (function() {
...
@@ -14,15 +12,7 @@ module.exports = (function() {
raw
:
false
raw
:
false
},
options
||
{})
},
options
||
{})
if
(
this
.
options
.
logging
===
true
)
{
this
.
checkLoggingOption
()
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
)
}
}
}
}
Utils
.
inherit
(
Query
,
AbstractQuery
)
Utils
.
inherit
(
Query
,
AbstractQuery
)
...
...
lib/dialects/sqlite/query.js
View file @
a35ed08
var
Utils
=
require
(
"../../utils"
)
var
Utils
=
require
(
"../../utils"
)
,
AbstractQuery
=
require
(
'../abstract/query'
)
,
AbstractQuery
=
require
(
'../abstract/query'
)
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
Query
=
function
(
database
,
sequelize
,
callee
,
options
)
{
var
Query
=
function
(
database
,
sequelize
,
callee
,
options
)
{
this
.
database
=
database
this
.
database
=
database
...
@@ -13,15 +12,7 @@ module.exports = (function() {
...
@@ -13,15 +12,7 @@ module.exports = (function() {
raw
:
false
raw
:
false
},
options
||
{})
},
options
||
{})
if
(
this
.
options
.
logging
===
true
)
{
this
.
checkLoggingOption
()
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
)
}
}
}
}
Utils
.
inherit
(
Query
,
AbstractQuery
)
Utils
.
inherit
(
Query
,
AbstractQuery
)
...
@@ -48,6 +39,7 @@ module.exports = (function() {
...
@@ -48,6 +39,7 @@ module.exports = (function() {
var
isInsertCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'insert'
)
==
0
)
var
isInsertCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'insert'
)
==
0
)
,
isUpdateCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'update'
)
==
0
)
,
isUpdateCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'update'
)
==
0
)
,
databaseMethod
=
(
isInsertCommand
||
isUpdateCommand
)
?
'run'
:
'all'
,
databaseMethod
=
(
isInsertCommand
||
isUpdateCommand
)
?
'run'
:
'all'
if
(
databaseMethod
===
'all'
&&
/select
\s
.*
?\s
from
\s
+
([^
;
]
+
)
/i
.
test
(
self
.
sql
))
{
if
(
databaseMethod
===
'all'
&&
/select
\s
.*
?\s
from
\s
+
([^
;
]
+
)
/i
.
test
(
self
.
sql
))
{
var
tableName
=
RegExp
.
$1
;
var
tableName
=
RegExp
.
$1
;
if
(
tableName
!==
'sqlite_master'
)
{
if
(
tableName
!==
'sqlite_master'
)
{
...
...
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