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 04b237e7
authored
Feb 28, 2014
by
Mick Hansen
Committed by
Thanasis Polychronakis
Mar 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consistency
1 parent
66fabc40
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
lib/associations/has-many.js
test/associations/has-many.test.js
lib/associations/has-many.js
View file @
04b237e
...
@@ -119,7 +119,7 @@ module.exports = (function() {
...
@@ -119,7 +119,7 @@ module.exports = (function() {
}
else
{
}
else
{
this
.
as
=
Utils
.
pluralize
(
this
.
target
.
name
,
this
.
target
.
options
.
language
)
this
.
as
=
Utils
.
pluralize
(
this
.
target
.
name
,
this
.
target
.
options
.
language
)
}
}
this
.
accessors
=
{
this
.
accessors
=
{
get
:
Utils
.
_
.
camelize
(
'get_'
+
this
.
as
),
get
:
Utils
.
_
.
camelize
(
'get_'
+
this
.
as
),
set
:
Utils
.
_
.
camelize
(
'set_'
+
this
.
as
),
set
:
Utils
.
_
.
camelize
(
'set_'
+
this
.
as
),
...
@@ -195,7 +195,7 @@ module.exports = (function() {
...
@@ -195,7 +195,7 @@ module.exports = (function() {
if
(
primaryKeyDeleted
)
{
if
(
primaryKeyDeleted
)
{
targetAttribute
.
primaryKey
=
sourceAttribute
.
primaryKey
=
true
targetAttribute
.
primaryKey
=
sourceAttribute
.
primaryKey
=
true
}
else
{
}
else
{
var
uniqueKey
=
[
this
.
through
.
tableName
,
this
.
identifier
,
this
.
foreignIdentifier
,
'unique'
].
join
(
'_'
)
var
uniqueKey
=
[
this
.
through
.
tableName
,
this
.
identifier
,
this
.
foreignIdentifier
,
'unique'
].
join
(
'_'
)
targetAttribute
.
unique
=
sourceAttribute
.
unique
=
uniqueKey
targetAttribute
.
unique
=
sourceAttribute
.
unique
=
uniqueKey
}
}
...
...
test/associations/has-many.test.js
View file @
04b237e
...
@@ -627,7 +627,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
...
@@ -627,7 +627,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
username
:
DataTypes
.
STRING
username
:
DataTypes
.
STRING
}).
schema
(
'acme'
,
'_'
)
}).
schema
(
'acme'
,
'_'
)
,
AcmeProject
=
self
.
sequelize
.
define
(
'Project'
,
{
,
AcmeProject
=
self
.
sequelize
.
define
(
'Project'
,
{
title
:
DataTypes
.
STRING
,
title
:
DataTypes
.
STRING
,
active
:
DataTypes
.
BOOLEAN
active
:
DataTypes
.
BOOLEAN
}).
schema
(
'acme'
,
'_'
)
}).
schema
(
'acme'
,
'_'
)
,
AcmeProjectUsers
=
self
.
sequelize
.
define
(
'ProjectUsers'
,
{
,
AcmeProjectUsers
=
self
.
sequelize
.
define
(
'ProjectUsers'
,
{
...
@@ -835,7 +835,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
...
@@ -835,7 +835,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
this
.
Task
.
hasMany
(
this
.
User
)
this
.
Task
.
hasMany
(
this
.
User
)
this
.
sequelize
.
sync
({
force
:
true
}).
success
(
function
()
{
this
.
sequelize
.
sync
({
force
:
true
}).
success
(
function
()
{
done
()
done
()
})
})
})
})
...
@@ -938,7 +938,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
...
@@ -938,7 +938,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})
})
})
})
})
})
describe
(
'primary key handling for join table'
,
function
()
{
describe
(
'primary key handling for join table'
,
function
()
{
beforeEach
(
function
(
done
)
{
beforeEach
(
function
(
done
)
{
var
self
=
this
var
self
=
this
...
@@ -966,7 +966,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
...
@@ -966,7 +966,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
it
(
'keeps the primary key if it was added by the user'
,
function
()
{
it
(
'keeps the primary key if it was added by the user'
,
function
()
{
var
self
=
this
var
self
=
this
,
fk
,
fk
this
.
UserTasks
=
this
.
sequelize
.
define
(
'usertasks'
,
{
this
.
UserTasks
=
this
.
sequelize
.
define
(
'usertasks'
,
{
id
:
{
id
:
{
type
:
Sequelize
.
INTEGER
,
type
:
Sequelize
.
INTEGER
,
...
@@ -980,14 +980,14 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
...
@@ -980,14 +980,14 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
autoincrement
:
true
,
autoincrement
:
true
,
primaryKey
:
true
primaryKey
:
true
}
}
});
});
this
.
User
.
hasMany
(
this
.
Task
,
{
through
:
this
.
UserTasks
})
this
.
User
.
hasMany
(
this
.
Task
,
{
through
:
this
.
UserTasks
})
this
.
Task
.
hasMany
(
this
.
User
,
{
through
:
this
.
UserTasks
})
this
.
Task
.
hasMany
(
this
.
User
,
{
through
:
this
.
UserTasks
})
this
.
User
.
hasMany
(
this
.
Task
,
{
through
:
this
.
UserTasks2
})
this
.
User
.
hasMany
(
this
.
Task
,
{
through
:
this
.
UserTasks2
})
this
.
Task
.
hasMany
(
this
.
User
,
{
through
:
this
.
UserTasks2
})
this
.
Task
.
hasMany
(
this
.
User
,
{
through
:
this
.
UserTasks2
})
expect
(
Object
.
keys
(
self
.
UserTasks
.
primaryKeys
)).
to
.
deep
.
equal
([
'id'
])
expect
(
Object
.
keys
(
self
.
UserTasks
.
primaryKeys
)).
to
.
deep
.
equal
([
'id'
])
expect
(
Object
.
keys
(
self
.
UserTasks2
.
primaryKeys
)).
to
.
deep
.
equal
([
'userTasksId'
])
expect
(
Object
.
keys
(
self
.
UserTasks2
.
primaryKeys
)).
to
.
deep
.
equal
([
'userTasksId'
])
...
@@ -997,7 +997,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
...
@@ -997,7 +997,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})
})
})
})
})
})
describe
(
'through'
,
function
()
{
describe
(
'through'
,
function
()
{
beforeEach
(
function
(
done
)
{
beforeEach
(
function
(
done
)
{
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{})
this
.
User
=
this
.
sequelize
.
define
(
'User'
,
{})
...
...
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