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 adfeea85
authored
Dec 09, 2014
by
Matt Broadstone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final cleanups based on PR feedback
1 parent
b2bcb304
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
24 deletions
.travis.yml
lib/dialects/mssql/query-generator.js
lib/dialects/mssql/query.js
lib/model.js
test/model/create.test.js
.travis.yml
View file @
adfeea8
...
@@ -40,6 +40,8 @@ matrix:
...
@@ -40,6 +40,8 @@ matrix:
allow_failures
:
allow_failures
:
-
node_js
:
"
0.10"
-
node_js
:
"
0.10"
env
:
COVERAGE=true
env
:
COVERAGE=true
-
node_js
:
"
0.10"
env
:
DB=mysql DIALECT=mssql
notifications
:
notifications
:
hipchat
:
hipchat
:
...
...
lib/dialects/mssql/query-generator.js
View file @
adfeea8
...
@@ -196,7 +196,7 @@ module.exports = (function() {
...
@@ -196,7 +196,7 @@ module.exports = (function() {
},
},
bulkInsertQuery
:
function
(
tableName
,
attrValueHashes
,
options
,
attributes
)
{
bulkInsertQuery
:
function
(
tableName
,
attrValueHashes
,
options
,
attributes
)
{
var
query
=
'INSERT
<%= ignoreDuplicates %>
INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %>;'
var
query
=
'INSERT INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %>;'
,
emptyQuery
=
'INSERT INTO <%= table %> DEFAULT VALUES'
,
emptyQuery
=
'INSERT INTO <%= table %> DEFAULT VALUES'
,
tuples
=
[]
,
tuples
=
[]
,
allAttributes
=
[]
,
allAttributes
=
[]
...
@@ -239,7 +239,6 @@ module.exports = (function() {
...
@@ -239,7 +239,6 @@ module.exports = (function() {
}
}
var
replacements
=
{
var
replacements
=
{
ignoreDuplicates
:
options
&&
options
.
ignoreDuplicates
?
' IGNORE'
:
''
,
table
:
this
.
quoteTable
(
tableName
),
table
:
this
.
quoteTable
(
tableName
),
attributes
:
allAttributes
.
map
(
function
(
attr
)
{
attributes
:
allAttributes
.
map
(
function
(
attr
)
{
return
this
.
quoteIdentifier
(
attr
);
return
this
.
quoteIdentifier
(
attr
);
...
...
lib/dialects/mssql/query.js
View file @
adfeea8
...
@@ -77,23 +77,10 @@ module.exports = (function() {
...
@@ -77,23 +77,10 @@ module.exports = (function() {
});
});
request
.
on
(
'row'
,
function
(
columns
)
{
request
.
on
(
'row'
,
function
(
columns
)
{
var
col
,
exi
,
row
,
_i
,
_len
;
var
row
=
{};
row
=
{};
columns
.
forEach
(
function
(
column
)
{
for
(
_i
=
0
,
_len
=
columns
.
length
;
_i
<
_len
;
_i
++
)
{
row
[
column
.
metadata
.
colName
]
=
column
.
value
;
col
=
columns
[
_i
];
});
/* col.value = valueCorrection(col.value, col.metadata); */
// exi = row[col.metadata.colName];
exi
=
null
;
if
(
exi
!==
null
)
{
if
(
exi
instanceof
Array
)
{
exi
.
push
(
col
.
value
);
}
else
{
row
[
col
.
metadata
.
colName
]
=
[
exi
,
col
.
value
];
}
}
else
{
row
[
col
.
metadata
.
colName
]
=
col
.
value
;
}
}
results
.
push
(
row
);
results
.
push
(
row
);
});
});
...
...
lib/model.js
View file @
adfeea8
...
@@ -1259,10 +1259,10 @@ module.exports = (function() {
...
@@ -1259,10 +1259,10 @@ module.exports = (function() {
}
}
var
dialect
=
this
.
sequelize
.
options
.
dialect
;
var
dialect
=
this
.
sequelize
.
options
.
dialect
;
if
(
options
.
ignoreDuplicates
&&
dialect
===
'postgres'
)
{
if
(
options
.
ignoreDuplicates
&&
[
'postgres'
,
'mssql'
].
indexOf
(
dialect
)
!==
-
1
)
{
return
Promise
.
reject
(
new
Error
(
'Postgres
does not support the \'ignoreDuplicates\' option.'
));
return
Promise
.
reject
(
new
Error
(
dialect
+
'
does not support the \'ignoreDuplicates\' option.'
));
}
}
if
(
options
.
updateOnDuplicate
&&
[
'mysql'
,
'mariadb'
,
'mssql'
].
indexOf
(
dialect
)
===
-
1
)
{
if
(
options
.
updateOnDuplicate
&&
[
'mysql'
,
'mariadb'
].
indexOf
(
dialect
)
===
-
1
)
{
return
Promise
.
reject
(
new
Error
(
dialect
+
' does not support the \'updateOnDuplicate\' option.'
));
return
Promise
.
reject
(
new
Error
(
dialect
+
' does not support the \'updateOnDuplicate\' option.'
));
}
}
...
...
test/model/create.test.js
View file @
adfeea8
...
@@ -1278,9 +1278,10 @@ describe(Support.getTestDialectTeaser("Model"), function () {
...
@@ -1278,9 +1278,10 @@ describe(Support.getTestDialectTeaser("Model"), function () {
self
.
User
.
bulkCreate
(
data
,
{
fields
:
[
'uniqueName'
,
'secretValue'
],
ignoreDuplicates
:
true
}).
error
(
function
(
err
)
{
self
.
User
.
bulkCreate
(
data
,
{
fields
:
[
'uniqueName'
,
'secretValue'
],
ignoreDuplicates
:
true
}).
error
(
function
(
err
)
{
expect
(
err
).
to
.
exist
expect
(
err
).
to
.
exist
if
(
dialect
===
'mssql'
)
{
if
(
dialect
===
'mssql'
)
{
expect
(
err
.
message
).
to
.
match
(
/MSSQL does not support the
\'
ignoreDuplicates
\'
option./
)
console
.
log
(
err
.
message
);
expect
(
err
.
message
).
to
.
match
(
/mssql does not support the
\'
ignoreDuplicates
\'
option./
)
}
else
{
}
else
{
expect
(
err
.
message
).
to
.
match
(
/
P
ostgres does not support the
\'
ignoreDuplicates
\'
option./
)
expect
(
err
.
message
).
to
.
match
(
/
p
ostgres does not support the
\'
ignoreDuplicates
\'
option./
)
}
}
done
();
done
();
...
...
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