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 e8f73c21
authored
Mar 23, 2014
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1544 from seegno/fix-fk-type-inference
Fix foreign key type inference
2 parents
70a0cb3e
71068a11
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletions
lib/associations/has-many.js
test/associations/has-many.test.js
lib/associations/has-many.js
View file @
e8f73c2
...
...
@@ -209,7 +209,7 @@ module.exports = (function() {
}
else
{
var
newAttributes
=
{}
var
constraintOptions
=
_
.
clone
(
this
.
options
)
// Create a new options object for use with addForeignKeyConstraints, to avoid polluting this.options in case it is later used for a n:m
newAttributes
[
this
.
identifier
]
=
{
type
:
this
.
options
.
keyType
||
this
.
target
.
rawAttributes
[
this
.
target
.
primaryKeyAttribute
].
type
}
newAttributes
[
this
.
identifier
]
=
{
type
:
this
.
options
.
keyType
||
this
.
source
.
rawAttributes
[
this
.
source
.
primaryKeyAttribute
].
type
}
if
(
this
.
options
.
constraints
!==
false
)
{
constraintOptions
.
onDelete
=
constraintOptions
.
onDelete
||
'SET NULL'
...
...
test/associations/has-many.test.js
View file @
e8f73c2
...
...
@@ -1732,5 +1732,24 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})
})
})
it
(
'infers the keyType if none provided'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
id
:
{
type
:
DataTypes
.
STRING
,
primaryKey
:
true
},
username
:
DataTypes
.
STRING
})
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
})
User
.
hasMany
(
Task
)
this
.
sequelize
.
sync
({
force
:
true
}).
success
(
function
()
{
expect
(
Task
.
rawAttributes
.
UserId
.
type
)
.
to
.
equal
(
DataTypes
.
STRING
)
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