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 b6a2c61f
authored
Mar 04, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove dao.instanceValues
1 parent
6f2072ae
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2 additions
and
86 deletions
lib/dao.js
test/dao-factory.test.js
test/dao-factory/find.test.js
test/dao-factory/findAll.test.js
lib/dao.js
View file @
b6a2c61
...
@@ -12,8 +12,6 @@ module.exports = (function() {
...
@@ -12,8 +12,6 @@ module.exports = (function() {
this
.
__options
=
this
.
Model
.
options
this
.
__options
=
this
.
Model
.
options
this
.
options
=
options
this
.
options
=
options
this
.
hasPrimaryKeys
=
this
.
Model
.
options
.
hasPrimaryKeys
this
.
hasPrimaryKeys
=
this
.
Model
.
options
.
hasPrimaryKeys
// What is selected values even used for?
this
.
selectedValues
=
options
.
include
?
_
.
omit
(
values
,
options
.
includeNames
)
:
values
this
.
__eagerlyLoadedAssociations
=
[]
this
.
__eagerlyLoadedAssociations
=
[]
this
.
isNewRecord
=
options
.
isNewRecord
this
.
isNewRecord
=
options
.
isNewRecord
...
...
test/dao-factory.test.js
View file @
b6a2c61
...
@@ -347,12 +347,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -347,12 +347,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
done
()
done
()
})
})
it
(
"stores the passed values in a special variable"
,
function
(
done
)
{
var
user
=
this
.
User
.
build
({
username
:
'John Wayne'
})
expect
(
user
.
selectedValues
).
to
.
deep
.
equal
({
username
:
'John Wayne'
})
done
()
})
it
(
"attaches getter and setter methods from attribute definition"
,
function
(
done
)
{
it
(
"attaches getter and setter methods from attribute definition"
,
function
(
done
)
{
var
Product
=
this
.
sequelize
.
define
(
'ProductWithSettersAndGetters1'
,
{
var
Product
=
this
.
sequelize
.
define
(
'ProductWithSettersAndGetters1'
,
{
price
:
{
price
:
{
...
...
test/dao-factory/find.test.js
View file @
b6a2c61
...
@@ -228,82 +228,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -228,82 +228,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
})
})
it
(
'returns the selected fields as instance.selectedValues'
,
function
(
done
)
{
var
self
=
this
this
.
User
.
create
({
username
:
'JohnXOXOXO'
}).
success
(
function
()
{
self
.
User
.
find
({
where
:
{
username
:
'JohnXOXOXO'
},
attributes
:
[
'username'
]
}).
done
(
function
(
err
,
user
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
_
.
omit
(
user
.
selectedValues
,
[
'id'
])).
to
.
have
.
property
(
'username'
,
'JohnXOXOXO'
)
done
()
})
})
})
it
(
'returns the selected fields and all fields of the included table as instance.selectedValues'
,
function
(
done
)
{
var
self
=
this
self
.
Mission
=
self
.
sequelize
.
define
(
'Mission'
,
{
title
:
{
type
:
Sequelize
.
STRING
,
defaultValue
:
'a mission!!'
},
foo
:
{
type
:
Sequelize
.
INTEGER
,
defaultValue
:
2
},
})
self
.
Mission
.
belongsTo
(
self
.
User
)
self
.
User
.
hasMany
(
self
.
Mission
)
self
.
Mission
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
Mission
.
create
().
success
(
function
(
mission
)
{
self
.
User
.
create
({
username
:
'John DOE'
}).
success
(
function
(
user
)
{
mission
.
setUser
(
user
).
success
(
function
()
{
self
.
User
.
find
({
where
:
{
username
:
'John DOE'
},
attributes
:
[
'username'
],
include
:
[
self
.
Mission
]
}).
done
(
function
(
err
,
user
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
_
.
omit
(
user
.
selectedValues
,
[
'id'
])).
to
.
deep
.
equal
({
username
:
'John DOE'
})
done
()
})
})
})
})
})
})
it
(
'returns the selected fields for both the base table and the included table as instance.selectedValues'
,
function
(
done
)
{
var
self
=
this
self
.
Mission
=
self
.
sequelize
.
define
(
'Mission'
,
{
title
:
{
type
:
Sequelize
.
STRING
,
defaultValue
:
'another mission!!'
},
foo
:
{
type
:
Sequelize
.
INTEGER
,
defaultValue
:
4
},
})
self
.
Mission
.
belongsTo
(
self
.
User
)
self
.
User
.
hasMany
(
self
.
Mission
)
self
.
Mission
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
Mission
.
create
().
success
(
function
(
mission
)
{
self
.
User
.
create
({
username
:
'Brain Picker'
}).
success
(
function
(
user
)
{
mission
.
setUser
(
user
).
success
(
function
()
{
self
.
User
.
find
({
where
:
{
username
:
'Brain Picker'
},
attributes
:
[
'username'
],
include
:
[{
model
:
self
.
Mission
,
as
:
self
.
Mission
.
tableName
,
attributes
:
[
'title'
]}]
}).
success
(
function
(
user
)
{
expect
(
_
.
omit
(
user
.
selectedValues
,
[
'id'
])).
to
.
deep
.
equal
({
username
:
'Brain Picker'
})
expect
(
user
.
missions
[
0
].
selectedValues
).
to
.
deep
.
equal
({
id
:
1
,
title
:
'another mission!!'
})
expect
(
user
.
missions
[
0
].
foo
).
not
.
to
.
exist
done
()
})
})
})
})
})
})
it
(
'always honors ZERO as primary key'
,
function
(
_done
)
{
it
(
'always honors ZERO as primary key'
,
function
(
_done
)
{
var
self
=
this
var
self
=
this
,
permutations
=
[
,
permutations
=
[
...
...
test/dao-factory/findAll.test.js
View file @
b6a2c61
...
@@ -1464,8 +1464,8 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -1464,8 +1464,8 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
expect
(
info
.
count
).
to
.
equal
(
2
)
expect
(
info
.
count
).
to
.
equal
(
2
)
expect
(
Array
.
isArray
(
info
.
rows
)).
to
.
be
.
ok
expect
(
Array
.
isArray
(
info
.
rows
)).
to
.
be
.
ok
expect
(
info
.
rows
.
length
).
to
.
equal
(
2
)
expect
(
info
.
rows
.
length
).
to
.
equal
(
2
)
expect
(
info
.
rows
[
0
].
selected
Values
).
to
.
not
.
have
.
property
(
'username'
)
expect
(
info
.
rows
[
0
].
data
Values
).
to
.
not
.
have
.
property
(
'username'
)
expect
(
info
.
rows
[
1
].
selected
Values
).
to
.
not
.
have
.
property
(
'username'
)
expect
(
info
.
rows
[
1
].
data
Values
).
to
.
not
.
have
.
property
(
'username'
)
done
()
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