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 195e8554
authored
Oct 06, 2014
by
Joel Trost
Committed by
Matt Broadstone
Dec 09, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed default select type
1 parent
8d9eb560
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
38 deletions
lib/dialects/mssql/query.js
test/model/create.test.js
test/query-interface.test.js
lib/dialects/mssql/query.js
View file @
195e855
...
...
@@ -114,38 +114,39 @@ module.exports = (function() {
*/
Query
.
prototype
.
formatResults
=
function
(
data
)
{
var
result
=
this
.
callee
;
if
(
this
.
isInsertQuery
(
data
))
{
this
.
handleInsertQuery
(
data
);
}
else
if
(
this
.
isShowTableQuery
())
{
result
=
this
.
handleShowTableQuery
(
data
);
}
else
if
(
this
.
isShowOrDescribeQuery
())
{
result
=
data
;
if
(
this
.
sql
.
toLowerCase
().
indexOf
(
"select c.name, t.name as 'type', c.is_nullable as isnull"
)
===
0
)
{
result
=
{};
data
.
forEach
(
function
(
_result
)
{
if
(
_result
.
Default
)
_result
.
Default
=
_result
.
Default
.
replace
(
'(\''
,
''
).
replace
(
'\')'
,
''
).
replace
(
/'/g
,
''
);
result
[
_result
.
Name
]
=
{
type
:
_result
.
Type
.
toUpperCase
(),
allowNull
:
_result
.
IsNull
,
defaultValue
:
_result
.
Default
};
});
}
else
if
(
this
.
isShowIndexesQuery
())
{
if
(
data
){
if
(
this
.
isInsertQuery
(
data
))
{
this
.
handleInsertQuery
(
data
);
}
else
if
(
this
.
isShowTableQuery
())
{
result
=
this
.
handleShowTableQuery
(
data
);
}
else
if
(
this
.
isShowOrDescribeQuery
())
{
result
=
data
;
}
}
else
if
(
this
.
isSelectQuery
())
{
result
=
this
.
handleSelectQuery
(
data
);
}
else
if
(
this
.
isCallQuery
())
{
result
=
data
[
0
];
}
else
if
(
this
.
isBulkUpdateQuery
()
||
this
.
isBulkDeleteQuery
())
{
result
=
data
.
affectedRows
;
}
else
{
if
(
this
.
options
.
type
&&
!
this
.
options
.
raw
){
if
(
this
.
sql
.
toLowerCase
().
indexOf
(
"select c.name, t.name as 'type', c.is_nullable as isnull"
)
===
0
)
{
result
=
{};
data
.
forEach
(
function
(
_result
)
{
if
(
_result
.
Default
)
_result
.
Default
=
_result
.
Default
.
replace
(
'(\''
,
''
).
replace
(
'\')'
,
''
).
replace
(
/'/g
,
''
);
result
[
_result
.
Name
]
=
{
type
:
_result
.
Type
.
toUpperCase
(),
allowNull
:
_result
.
IsNull
,
defaultValue
:
_result
.
Default
};
});
}
else
if
(
this
.
isShowIndexesQuery
())
{
result
=
data
;
}
}
else
if
(
this
.
isSelectQuery
())
{
result
=
this
.
handleSelectQuery
(
data
);
}
else
if
(
this
.
isCallQuery
())
{
result
=
data
[
0
];
}
else
if
(
this
.
isBulkUpdateQuery
()
||
this
.
isBulkDeleteQuery
())
{
result
=
data
.
affectedRows
;
}
else
{
result
=
this
.
handleSelectQuery
(
data
);
}
else
{
result
=
data
;
}
}
else
{
result
=
data
;
}
return
result
;
};
...
...
test/model/create.test.js
View file @
195e855
...
...
@@ -991,9 +991,9 @@ describe(Support.getTestDialectTeaser("Model"), function () {
it
(
'properly handles disparate field lists'
,
function
(
done
)
{
var
self
=
this
,
data
=
[{
username
:
'Peter'
,
secretValue
:
'42'
},
{
username
:
'Paul'
},
{
username
:
'Steve'
}]
,
data
=
[{
username
:
'Peter'
,
secretValue
:
'42'
,
uniqueName
:
'1'
},
{
username
:
'Paul'
,
uniqueName
:
'2'
},
{
username
:
'Steve'
,
uniqueName
:
'3'
}]
this
.
User
.
bulkCreate
(
data
).
success
(
function
()
{
self
.
User
.
findAll
({
where
:
{
username
:
'Paul'
}}).
success
(
function
(
users
)
{
...
...
@@ -1007,10 +1007,10 @@ describe(Support.getTestDialectTeaser("Model"), function () {
it
(
'inserts multiple values respecting the white list'
,
function
(
done
)
{
var
self
=
this
,
data
=
[{
username
:
'Peter'
,
secretValue
:
'42'
},
{
username
:
'Paul'
,
secretValue
:
'23'
}]
,
data
=
[{
username
:
'Peter'
,
secretValue
:
'42'
,
uniqueName
:
'1'
},
{
username
:
'Paul'
,
secretValue
:
'23'
,
uniqueName
:
'2'
}]
this
.
User
.
bulkCreate
(
data
,
{
fields
:
[
'username'
]
}).
success
(
function
()
{
this
.
User
.
bulkCreate
(
data
,
{
fields
:
[
'username'
,
'uniqueName'
]
}).
success
(
function
()
{
self
.
User
.
findAll
({
order
:
'id'
}).
success
(
function
(
users
)
{
expect
(
users
.
length
).
to
.
equal
(
2
)
expect
(
users
[
0
].
username
).
to
.
equal
(
"Peter"
)
...
...
@@ -1024,8 +1024,8 @@ describe(Support.getTestDialectTeaser("Model"), function () {
it
(
'should store all values if no whitelist is specified'
,
function
(
done
)
{
var
self
=
this
,
data
=
[{
username
:
'Peter'
,
secretValue
:
'42'
},
{
username
:
'Paul'
,
secretValue
:
'23'
}]
,
data
=
[{
username
:
'Peter'
,
secretValue
:
'42'
,
uniqueName
:
'1'
},
{
username
:
'Paul'
,
secretValue
:
'23'
,
uniqueName
:
'2'
}]
this
.
User
.
bulkCreate
(
data
).
success
(
function
()
{
self
.
User
.
findAll
({
order
:
'id'
}).
success
(
function
(
users
)
{
...
...
test/query-interface.test.js
View file @
195e855
...
...
@@ -99,7 +99,6 @@ describe(Support.getTestDialectTeaser("QueryInterface"), function () {
self
.
queryInterface
.
showIndex
(
'Group'
).
complete
(
function
(
err
,
indexes
)
{
expect
(
err
).
to
.
be
.
null
console
.
log
(
indexes
);
indexColumns
=
_
.
uniq
(
indexes
.
map
(
function
(
index
)
{
return
index
.
name
}))
expect
(
indexColumns
).
to
.
be
.
empty
...
...
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