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 79b80a8e
authored
Sep 25, 2014
by
Joel Trost
Committed by
Matt Broadstone
Dec 09, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug in lib/model.js deleting clauses
1 parent
da053191
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
12 deletions
lib/dialects/abstract/query-generator.js
lib/dialects/mssql/query-generator.js
lib/dialects/mssql/sql-generator.js
lib/model.js
lib/dialects/abstract/query-generator.js
View file @
79b80a8
...
@@ -780,7 +780,6 @@ module.exports = (function() {
...
@@ -780,7 +780,6 @@ module.exports = (function() {
selectQuery
:
function
(
tableName
,
options
,
model
)
{
selectQuery
:
function
(
tableName
,
options
,
model
)
{
// Enter and change at your own peril -- Mick Hansen
// Enter and change at your own peril -- Mick Hansen
options
=
options
||
{};
options
=
options
||
{};
var
table
=
null
var
table
=
null
...
@@ -1259,7 +1258,7 @@ module.exports = (function() {
...
@@ -1259,7 +1258,7 @@ module.exports = (function() {
}
}
query
+=
';'
;
query
+=
';'
;
console
.
log
(
query
);
//
console.log(query);
return
query
;
return
query
;
},
},
...
...
lib/dialects/mssql/query-generator.js
View file @
79b80a8
...
@@ -383,6 +383,7 @@ module.exports = (function() {
...
@@ -383,6 +383,7 @@ module.exports = (function() {
//console.log('tablename', tableName);
//console.log('tablename', tableName);
//console.log('options', options);
//console.log('options', options);
//console.log('model', model);
//console.log('model', model);
//console.log(options.where);
options
=
options
||
{};
options
=
options
||
{};
var
query
=
[
var
query
=
[
...
@@ -395,8 +396,10 @@ module.exports = (function() {
...
@@ -395,8 +396,10 @@ module.exports = (function() {
query
.
push
(
SqlGenerator
.
getJoinClause
(
model
,
options
.
include
[
i
]));
query
.
push
(
SqlGenerator
.
getJoinClause
(
model
,
options
.
include
[
i
]));
}
}
}
}
if
(
options
.
hasOwnProperty
(
'where'
)){
console
.
log
(
query
);
query
.
push
(
this
.
getWhereConditions
(
options
.
where
,
model
.
name
,
model
,
options
));
}
//console.log(query);
return
query
.
join
(
' '
)
+
';'
;
return
query
.
join
(
' '
)
+
';'
;
},
},
/**
/**
...
@@ -483,8 +486,18 @@ module.exports = (function() {
...
@@ -483,8 +486,18 @@ module.exports = (function() {
/*
/*
Takes something and transforms it into values of a where condition.
Takes something and transforms it into values of a where condition.
*/
*/
getWhereConditions
:
function
(
smth
,
tableName
,
factory
,
options
,
prepend
)
{
/*
throwMethodUndefined
(
'getWhereConditions'
);
Takes something and transforms it into values of a where condition.
*/
getWhereConditions
:
function
(
smth
,
tableName
,
model
,
options
,
prepend
)
{
//console.log('where:', model);
//console.log('logic', smth);
if
(
!
smth
){
return
SqlGenerator
.
getWhereClause
(
tableName
,
model
,
options
);
}
else
{
return
''
;
}
},
},
prependTableNameToHash
:
function
(
tableName
,
hash
)
{
prependTableNameToHash
:
function
(
tableName
,
hash
)
{
...
...
lib/dialects/mssql/sql-generator.js
View file @
79b80a8
...
@@ -490,14 +490,26 @@ module.exports = {
...
@@ -490,14 +490,26 @@ module.exports = {
var
primaryKey
=
''
;
var
primaryKey
=
''
;
for
(
var
key
in
model
.
rawAttributes
){
for
(
var
key
in
model
.
rawAttributes
){
if
(
model
.
rawAttributes
[
key
].
primaryKey
){
if
(
model
.
rawAttributes
[
key
].
primaryKey
){
primaryKey
=
key
;
primaryKey
=
quoteIdentifier
(
key
)
;
break
;
break
;
}
}
}
}
console
.
log
(
include
.
association
.
foreignKey
);
var
joinType
=
include
.
required
?
'INNER JOIN'
:
'LEFT OUTER JOIN'
;
console
.
log
(
primaryKey
);
//for(var i = 0; i < )
var
joinTable
=
include
.
as
?
include
.
as
:
include
.
model
.
name
;
var
joinType
=
include
.
required
?
' INNER JOIN '
:
' LEFT OUTER JOIN '
;
joinTable
=
quoteIdentifier
(
joinTable
);
var
tableName
=
quoteIdentifier
(
model
.
name
);
//console.log(include);
return
[
joinType
,
quoteIdentifier
(
include
.
model
.
tableName
),
'AS'
,
joinTable
,
'ON'
,
tableName
+
'.'
+
primaryKey
,
'='
,
joinTable
+
'.'
+
quoteIdentifier
(
include
.
association
.
foreignKey
)
].
join
(
' '
);
},
getWhereClause
:
function
(
tableName
,
model
,
options
){
//console.log('my model:', model);
}
}
};
};
...
...
lib/model.js
View file @
79b80a8
...
@@ -689,7 +689,6 @@ module.exports = (function() {
...
@@ -689,7 +689,6 @@ module.exports = (function() {
}
}
}).
then
(
function
()
{
}).
then
(
function
()
{
expandIncludeAll
.
call
(
this
,
options
);
expandIncludeAll
.
call
(
this
,
options
);
if
(
options
.
hooks
)
{
if
(
options
.
hooks
)
{
return
this
.
runHooks
(
'beforeFindAfterExpandIncludeAll'
,
options
);
return
this
.
runHooks
(
'beforeFindAfterExpandIncludeAll'
,
options
);
}
}
...
...
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