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 45a56dcb
authored
Aug 23, 2013
by
whito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
find a string based primaryKey called id
1 parent
d633069a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletions
lib/dao-factory.js
test/dao-factory.test.js
lib/dao-factory.js
View file @
45a56dc
...
...
@@ -101,7 +101,7 @@ module.exports = (function() {
this
.
primaryKeys
=
{};
Utils
.
_
.
each
(
this
.
attributes
,
function
(
dataTypeString
,
attributeName
)
{
if
(
(
attributeName
!==
'id'
)
&&
(
dataTypeString
.
indexOf
(
'PRIMARY KEY'
)
!==
-
1
)
)
{
if
(
dataTypeString
.
indexOf
(
'PRIMARY KEY'
)
!==
-
1
)
{
self
.
primaryKeys
[
attributeName
]
=
dataTypeString
}
})
...
...
test/dao-factory.test.js
View file @
45a56dc
...
...
@@ -1490,6 +1490,30 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it
(
'finds entries via a string primary key called id'
,
function
(
done
)
{
var
self
=
this
,
UserPrimary
=
self
.
sequelize
.
define
(
'UserWithPrimaryKey'
,
{
id
:
{
type
:
Sequelize
.
STRING
,
primaryKey
:
true
},
name
:
Sequelize
.
STRING
})
UserPrimary
.
sync
({
force
:
true
}).
success
(
function
()
{
UserPrimary
.
create
({
id
:
'a string based id'
,
name
:
'John'
}).
success
(
function
(
u
)
{
expect
(
u
.
id
).
not
.
to
.
exist
UserPrimary
.
find
(
'a string based id'
).
success
(
function
(
u2
)
{
expect
(
u2
.
id
).
to
.
equal
(
'a string based id'
)
expect
(
u2
.
name
).
to
.
equal
(
'John'
)
done
()
})
})
})
})
it
(
'returns the selected fields as instance.selectedValues'
,
function
(
done
)
{
var
self
=
this
this
.
User
.
create
({
...
...
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