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 2ac4a59b
authored
Jan 31, 2014
by
Michael Schonfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use a custom emitter to throw the error; then test for it
1 parent
4bbd0aab
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
8 deletions
lib/dao-factory.js
lib/dialects/postgres/query-generator.js
test/dao-factory/create.test.js
lib/dao-factory.js
View file @
2ac4a59
...
@@ -789,6 +789,12 @@ module.exports = (function() {
...
@@ -789,6 +789,12 @@ module.exports = (function() {
options
=
Utils
.
_
.
extend
(
options
,
fieldsOrOptions
)
options
=
Utils
.
_
.
extend
(
options
,
fieldsOrOptions
)
}
}
if
(
this
.
daoFactoryManager
.
sequelize
.
options
.
dialect
===
'postgres'
&&
options
.
ignoreDuplicates
)
{
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
emitter
.
emit
(
'error'
,
new
Error
(
'Postgres does not support the \'ignoreDuplicates\' option.'
))
}).
run
();
}
var
self
=
this
var
self
=
this
,
updatedAtAttr
=
Utils
.
_
.
underscoredIf
(
self
.
options
.
updatedAt
,
self
.
options
.
underscored
)
,
updatedAtAttr
=
Utils
.
_
.
underscoredIf
(
self
.
options
.
updatedAt
,
self
.
options
.
underscored
)
,
createdAtAttr
=
Utils
.
_
.
underscoredIf
(
self
.
options
.
createdAt
,
self
.
options
.
underscored
)
,
createdAtAttr
=
Utils
.
_
.
underscoredIf
(
self
.
options
.
createdAt
,
self
.
options
.
underscored
)
...
...
lib/dialects/postgres/query-generator.js
View file @
2ac4a59
...
@@ -268,10 +268,6 @@ module.exports = (function() {
...
@@ -268,10 +268,6 @@ module.exports = (function() {
},
},
bulkInsertQuery
:
function
(
tableName
,
attrValueHashes
,
options
)
{
bulkInsertQuery
:
function
(
tableName
,
attrValueHashes
,
options
)
{
if
(
options
&&
options
.
ignoreDuplicates
)
{
throw
new
Error
(
"Postgres does not support the 'ignoreDuplicates' option."
)
}
var
query
=
"INSERT INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %> RETURNING *;"
var
query
=
"INSERT INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %> RETURNING *;"
,
tuples
=
[]
,
tuples
=
[]
,
serials
=
[]
,
serials
=
[]
...
...
test/dao-factory/create.test.js
View file @
2ac4a59
...
@@ -1021,10 +1021,14 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -1021,10 +1021,14 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this
.
User
.
bulkCreate
(
data
,
{
fields
:
[
'uniqueName'
,
'secretValue'
]
}).
success
(
function
()
{
this
.
User
.
bulkCreate
(
data
,
{
fields
:
[
'uniqueName'
,
'secretValue'
]
}).
success
(
function
()
{
data
.
push
({
uniqueName
:
'Michael'
,
secretValue
:
'26'
});
data
.
push
({
uniqueName
:
'Michael'
,
secretValue
:
'26'
});
self
.
User
.
bulkCreate
(
data
,
{
fields
:
[
'uniqueName'
,
'secretValue'
],
ignoreDuplicates
:
true
}).
success
(
function
()
{
expect
(
err
.
message
).
to
.
match
(
/Postgres does not support the 'ignoreDuplicates' option./
);
self
.
User
.
bulkCreate
(
data
,
{
fields
:
[
'uniqueName'
,
'secretValue'
],
ignoreDuplicates
:
true
}).
error
(
function
(
err
)
{
done
()
console
.
log
(
'err?'
,
err
)
});
expect
(
err
).
to
.
exist
expect
(
err
.
message
).
to
.
match
(
/Postgres does not support the
\'
ignoreDuplicates
\'
option./
)
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