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 0c591847
authored
Jun 10, 2013
by
durango
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #689 from janmeier/pgID
Fixes #644
2 parents
7db160ca
872a0bea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletions
lib/dialects/postgres/query-generator.js
spec/dao-factory.spec.js
lib/dialects/postgres/query-generator.js
View file @
0c59184
...
@@ -292,7 +292,18 @@ module.exports = (function() {
...
@@ -292,7 +292,18 @@ module.exports = (function() {
attrValueHash
=
Utils
.
removeNullValuesFromHash
(
attrValueHash
,
this
.
options
.
omitNull
)
attrValueHash
=
Utils
.
removeNullValuesFromHash
(
attrValueHash
,
this
.
options
.
omitNull
)
var
query
=
"INSERT INTO <%= table %> (<%= attributes %>) VALUES (<%= values %>) RETURNING *;"
var
query
=
"INSERT INTO <%= table %> (<%= attributes %>) VALUES (<%= values %>) RETURNING *;"
,
returning
=
removeSerialsFromHash
(
tableName
,
attrValueHash
)
// Remove serials that are null or undefined, which causes an error in PG
Utils
.
_
.
forEach
(
attrValueHash
,
function
(
value
,
key
,
hash
)
{
if
(
tables
[
tableName
])
{
switch
(
tables
[
tableName
][
key
])
{
case
'bigserial'
:
case
'serial'
:
if
([
null
,
undefined
].
indexOf
(
hash
[
key
])
!==
-
1
)
delete
hash
[
key
]
break
}
}
});
var
replacements
=
{
var
replacements
=
{
table
:
this
.
quoteIdentifiers
(
tableName
)
table
:
this
.
quoteIdentifiers
(
tableName
)
...
...
spec/dao-factory.spec.js
View file @
0c59184
...
@@ -518,6 +518,17 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
...
@@ -518,6 +518,17 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
})
})
})
})
it
(
'allows setting custom IDs'
,
function
(
done
)
{
this
.
User
.
create
({
id
:
42
}).
success
(
function
(
user
)
{
expect
(
user
.
id
).
toEqual
(
42
)
this
.
User
.
find
(
42
).
success
(
function
(
user
)
{
expect
(
user
).
toBeDefined
()
done
()
})
}.
bind
(
this
))
})
describe
(
'enums'
,
function
()
{
describe
(
'enums'
,
function
()
{
before
(
function
(
done
)
{
before
(
function
(
done
)
{
this
.
Item
=
this
.
sequelize
.
define
(
'Item'
,
{
this
.
Item
=
this
.
sequelize
.
define
(
'Item'
,
{
...
...
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