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 589a90b1
authored
May 27, 2014
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed foreignKeyObject to foreignKeyAttribute
1 parent
b11f57f3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
14 deletions
lib/associations/belongs-to.js
lib/associations/has-many.js
lib/associations/has-one.js
lib/associations/belongs-to.js
View file @
589a90b
...
...
@@ -15,10 +15,10 @@ module.exports = (function() {
this
.
as
=
this
.
options
.
as
;
if
(
Utils
.
_
.
isObject
(
this
.
options
.
foreignKey
))
{
this
.
foreignKey
Object
=
this
.
options
.
foreignKey
;
this
.
foreignKey
=
this
.
foreignKey
Object
.
fieldName
;
this
.
foreignKey
Attribute
=
this
.
options
.
foreignKey
;
this
.
foreignKey
=
this
.
foreignKey
Attribute
.
fieldName
;
}
else
{
this
.
foreignKey
Object
=
{};
this
.
foreignKey
Attribute
=
{};
this
.
foreignKey
=
this
.
options
.
foreignKey
;
}
...
...
@@ -54,7 +54,7 @@ module.exports = (function() {
BelongsTo
.
prototype
.
injectAttributes
=
function
()
{
var
newAttributes
=
{};
newAttributes
[
this
.
identifier
]
=
Utils
.
_
.
defaults
(
this
.
foreignKey
Object
,
{
type
:
this
.
options
.
keyType
||
this
.
target
.
rawAttributes
[
this
.
targetIdentifier
].
type
});
newAttributes
[
this
.
identifier
]
=
Utils
.
_
.
defaults
(
this
.
foreignKey
Attribute
,
{
type
:
this
.
options
.
keyType
||
this
.
target
.
rawAttributes
[
this
.
targetIdentifier
].
type
});
if
(
this
.
options
.
constraints
!==
false
)
{
this
.
options
.
onDelete
=
this
.
options
.
onDelete
||
'SET NULL'
;
this
.
options
.
onUpdate
=
this
.
options
.
onUpdate
||
'CASCADE'
;
...
...
lib/associations/has-many.js
View file @
589a90b
...
...
@@ -29,10 +29,10 @@ module.exports = (function() {
);
if
(
Utils
.
_
.
isObject
(
this
.
options
.
foreignKey
))
{
this
.
foreignKey
Object
=
this
.
options
.
foreignKey
;
this
.
foreignKey
=
this
.
foreignKey
Object
.
fieldName
;
this
.
foreignKey
Attribute
=
this
.
options
.
foreignKey
;
this
.
foreignKey
=
this
.
foreignKey
Attribute
.
fieldName
;
}
else
{
this
.
foreignKey
Object
=
{};
this
.
foreignKey
Attribute
=
{};
this
.
foreignKey
=
this
.
options
.
foreignKey
;
}
...
...
@@ -206,8 +206,8 @@ module.exports = (function() {
// define a new model, which connects the models
var
sourceKeyType
=
this
.
source
.
rawAttributes
[
this
.
source
.
primaryKeyAttribute
].
type
,
targetKeyType
=
this
.
target
.
rawAttributes
[
this
.
target
.
primaryKeyAttribute
].
type
,
sourceAttribute
=
Utils
.
_
.
defaults
(
this
.
foreignKey
Object
,
{
type
:
sourceKeyType
})
,
targetAttribute
=
Utils
.
_
.
defaults
(
this
.
targetAssociation
.
foreignKey
Object
,
{
type
:
targetKeyType
});
,
sourceAttribute
=
Utils
.
_
.
defaults
(
this
.
foreignKey
Attribute
,
{
type
:
sourceKeyType
})
,
targetAttribute
=
Utils
.
_
.
defaults
(
this
.
targetAssociation
.
foreignKey
Attribute
,
{
type
:
targetKeyType
});
if
(
this
.
options
.
constraints
!==
false
)
{
sourceAttribute
.
references
=
this
.
source
.
getTableName
();
...
...
@@ -248,7 +248,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
]
=
_
.
defaults
(
this
.
foreignKey
Object
,
{
type
:
this
.
options
.
keyType
||
this
.
source
.
rawAttributes
[
this
.
source
.
primaryKeyAttribute
].
type
});
newAttributes
[
this
.
identifier
]
=
_
.
defaults
(
this
.
foreignKey
Attribute
,
{
type
:
this
.
options
.
keyType
||
this
.
source
.
rawAttributes
[
this
.
source
.
primaryKeyAttribute
].
type
});
if
(
this
.
options
.
constraints
!==
false
)
{
constraintOptions
.
onDelete
=
constraintOptions
.
onDelete
||
'SET NULL'
;
...
...
lib/associations/has-one.js
View file @
589a90b
...
...
@@ -15,10 +15,10 @@ module.exports = (function() {
this
.
as
=
this
.
options
.
as
;
if
(
Utils
.
_
.
isObject
(
this
.
options
.
foreignKey
))
{
this
.
foreignKey
Object
=
this
.
options
.
foreignKey
;
this
.
foreignKey
=
this
.
foreignKey
Object
.
fieldName
;
this
.
foreignKey
Attribute
=
this
.
options
.
foreignKey
;
this
.
foreignKey
=
this
.
foreignKey
Attribute
.
fieldName
;
}
else
{
this
.
foreignKey
Object
=
{};
this
.
foreignKey
Attribute
=
{};
this
.
foreignKey
=
this
.
options
.
foreignKey
;
}
...
...
@@ -55,7 +55,7 @@ module.exports = (function() {
var
newAttributes
=
{}
,
keyType
=
this
.
source
.
rawAttributes
[
this
.
sourceIdentifier
].
type
;
newAttributes
[
this
.
identifier
]
=
Utils
.
_
.
defaults
(
this
.
foreignKey
Object
,
{
type
:
this
.
options
.
keyType
||
keyType
});
newAttributes
[
this
.
identifier
]
=
Utils
.
_
.
defaults
(
this
.
foreignKey
Attribute
,
{
type
:
this
.
options
.
keyType
||
keyType
});
Utils
.
_
.
defaults
(
this
.
target
.
rawAttributes
,
newAttributes
);
if
(
this
.
options
.
constraints
!==
false
)
{
...
...
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