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 8731f222
authored
Mar 06, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'patch-issue-3279' of
https://github.com/ackerdev/sequelize
into ac…
…kerdev-patch-issue-3279
2 parents
a72981c6
9e6b0610
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
2 deletions
lib/dialects/abstract/query-generator.js
test/integration/associations/belongs-to-many.test.js
lib/dialects/abstract/query-generator.js
View file @
8731f22
...
@@ -971,7 +971,7 @@ module.exports = (function() {
...
@@ -971,7 +971,7 @@ module.exports = (function() {
,
primaryKeysSource
=
association
.
source
.
primaryKeyAttributes
,
primaryKeysSource
=
association
.
source
.
primaryKeyAttributes
,
tableSource
=
parentTable
,
tableSource
=
parentTable
,
identSource
=
association
.
identifierField
,
identSource
=
association
.
identifierField
,
attrSource
=
association
.
source
.
rawAttributes
[
primaryKeysSource
[
0
]].
field
||
primaryKeysSource
[
0
]
,
attrSource
=
primaryKeysSource
[
0
]
,
where
,
where
,
primaryKeysTarget
=
association
.
target
.
primaryKeyAttributes
,
primaryKeysTarget
=
association
.
target
.
primaryKeyAttributes
...
...
test/integration/associations/belongs-to-many.test.js
View file @
8731f22
...
@@ -246,7 +246,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
...
@@ -246,7 +246,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
});
});
var
User_has_Group
=
this
.
sequelize
.
define
(
'User_has_Group'
,
{
var
User_has_Group
=
this
.
sequelize
.
define
(
'User_has_Group'
,
{
},
{
},
{
tableName
:
'tbl_user_has_group'
tableName
:
'tbl_user_has_group'
});
});
...
@@ -269,6 +269,57 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
...
@@ -269,6 +269,57 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
});
});
});
});
});
});
it
(
'supports primary key attributes with different field names'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
id
:
{
type
:
DataTypes
.
UUID
,
allowNull
:
false
,
primaryKey
:
true
,
defaultValue
:
DataTypes
.
UUIDV4
,
field
:
'user_id'
}
},
{
tableName
:
'tbl_user'
});
var
Group
=
this
.
sequelize
.
define
(
'Group'
,
{
id
:
{
type
:
DataTypes
.
UUID
,
allowNull
:
false
,
primaryKey
:
true
,
defaultValue
:
DataTypes
.
UUIDV4
,
field
:
'group_id'
}
},
{
tableName
:
'tbl_group'
});
var
User_has_Group
=
this
.
sequelize
.
define
(
'User_has_Group'
,
{
},
{
tableName
:
'tbl_user_has_group'
});
User
.
belongsToMany
(
Group
,
{
through
:
User_has_Group
});
Group
.
belongsToMany
(
User
,
{
through
:
User_has_Group
});
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
join
(
User
.
create
(),
Group
.
create
()
).
spread
(
function
(
user
,
group
)
{
return
user
.
addGroup
(
group
);
}).
then
(
function
()
{
return
User
.
findOne
({
where
:
{},
include
:
Group
}).
then
(
function
(
user
)
{
return
user
;
});
});
});
});
});
});
describe
(
'setAssociations'
,
function
()
{
describe
(
'setAssociations'
,
function
()
{
...
...
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