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 fad4b39b
authored
Jul 29, 2013
by
Daniel Durante
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Postgres association tests should pass properly now.
1 parent
71c40d61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
64 deletions
test/postgres/associations.test.js
test/postgres/associations.test.js
View file @
fad4b39
...
...
@@ -46,53 +46,46 @@ if (dialect.match(/^postgres/)) {
})
describe
(
'HasMany'
,
function
()
{
beforeEach
(
function
(
done
)
{
//prevent periods from occurring in the table name since they are used to delimit (table.column)
this
.
User
=
this
.
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
DataTypes
.
STRING
})
this
.
Task
=
this
.
sequelize
.
define
(
'Task'
+
config
.
rand
(),
{
name
:
DataTypes
.
STRING
})
this
.
users
=
null
this
.
tasks
=
null
this
.
User
.
hasMany
(
this
.
Task
,
{
as
:
'Tasks'
})
this
.
Task
.
hasMany
(
this
.
User
,
{
as
:
'Users'
})
var
self
=
this
,
users
=
[]
,
tasks
=
[]
for
(
var
i
=
0
;
i
<
5
;
++
i
)
{
users
[
users
.
length
]
=
{
name
:
'User'
+
Math
.
random
()}
}
for
(
var
x
=
0
;
x
<
5
;
++
x
)
{
tasks
[
tasks
.
length
]
=
{
name
:
'Task'
+
Math
.
random
()}
}
self
.
sequelize
.
getQueryInterface
().
dropAllTables
().
success
(
function
()
{
self
.
User
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
Task
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
User
.
bulkCreate
(
users
).
success
(
function
()
{
self
.
Task
.
bulkCreate
(
tasks
).
success
(
function
()
{
done
()
})
})
})
})
})
})
describe
(
'addDAO / getDAO'
,
function
()
{
beforeEach
(
function
(
done
)
{
var
self
=
this
self
.
user
=
null
self
.
task
=
null
//prevent periods from occurring in the table name since they are used to delimit (table.column)
this
.
User
=
this
.
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
DataTypes
.
STRING
})
this
.
Task
=
this
.
sequelize
.
define
(
'Task'
+
config
.
rand
(),
{
name
:
DataTypes
.
STRING
})
this
.
users
=
null
this
.
tasks
=
null
this
.
User
.
hasMany
(
this
.
Task
,
{
as
:
'Tasks'
})
this
.
Task
.
hasMany
(
this
.
User
,
{
as
:
'Users'
})
self
.
User
.
all
().
success
(
function
(
_users
)
{
self
.
Task
.
all
().
success
(
function
(
_tasks
)
{
self
.
user
=
_users
[
0
]
self
.
task
=
_tasks
[
0
]
done
()
var
self
=
this
,
users
=
[]
,
tasks
=
[]
for
(
var
i
=
0
;
i
<
5
;
++
i
)
{
users
[
users
.
length
]
=
{
name
:
'User'
+
Math
.
random
()}
}
for
(
var
x
=
0
;
x
<
5
;
++
x
)
{
tasks
[
tasks
.
length
]
=
{
name
:
'Task'
+
Math
.
random
()}
}
self
.
sequelize
.
getQueryInterface
().
dropAllTables
().
success
(
function
()
{
self
.
User
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
Task
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
User
.
bulkCreate
(
users
).
success
(
function
()
{
self
.
Task
.
bulkCreate
(
tasks
).
success
(
function
()
{
self
.
User
.
all
().
success
(
function
(
_users
)
{
self
.
Task
.
all
().
success
(
function
(
_tasks
)
{
self
.
user
=
_users
[
0
]
self
.
task
=
_tasks
[
0
]
done
()
})
})
})
})
})
})
})
})
...
...
@@ -113,33 +106,54 @@ if (dialect.match(/^postgres/)) {
})
describe
(
'removeDAO'
,
function
()
{
beforeEach
(
function
(
done
)
{
it
(
"should correctly remove associated objects"
,
function
(
done
)
{
var
self
=
this
,
users
=
[]
,
tasks
=
[]
self
.
user
=
null
self
.
tasks
=
null
//prevent periods from occurring in the table name since they are used to delimit (table.column)
this
.
User
=
this
.
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
DataTypes
.
STRING
})
this
.
Task
=
this
.
sequelize
.
define
(
'Task'
+
config
.
rand
(),
{
name
:
DataTypes
.
STRING
})
this
.
users
=
null
this
.
tasks
=
null
self
.
User
.
all
().
success
(
function
(
_users
)
{
self
.
Task
.
all
().
success
(
function
(
_tasks
)
{
self
.
user
=
_users
[
0
]
self
.
tasks
=
_tasks
done
()
})
})
})
this
.
User
.
hasMany
(
this
.
Task
,
{
as
:
'Tasks'
})
this
.
Task
.
hasMany
(
this
.
User
,
{
as
:
'Users'
})
it
(
"should correctly remove associated objects"
,
function
(
done
)
{
var
self
=
this
for
(
var
i
=
0
;
i
<
5
;
++
i
)
{
users
[
users
.
length
]
=
{
id
:
i
,
name
:
'User'
+
Math
.
random
()}
}
self
.
user
.
getTasks
().
on
(
'success'
,
function
(
__tasks
)
{
expect
(
__tasks
).
to
.
have
.
length
(
0
)
self
.
user
.
setTasks
(
self
.
tasks
).
on
(
'success'
,
function
()
{
self
.
user
.
getTasks
().
on
(
'success'
,
function
(
_tasks
)
{
expect
(
_tasks
).
to
.
have
.
length
(
self
.
tasks
.
length
)
self
.
user
.
removeTask
(
self
.
tasks
[
0
]).
on
(
'success'
,
function
()
{
self
.
user
.
getTasks
().
on
(
'success'
,
function
(
_tasks
)
{
expect
(
_tasks
).
to
.
have
.
length
(
self
.
tasks
.
length
-
1
)
done
()
for
(
var
x
=
0
;
x
<
5
;
++
x
)
{
tasks
[
tasks
.
length
]
=
{
id
:
i
,
name
:
'Task'
+
Math
.
random
()}
}
self
.
User
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
Task
.
sync
({
force
:
true
}).
success
(
function
()
{
self
.
User
.
bulkCreate
(
users
).
success
(
function
()
{
self
.
Task
.
bulkCreate
(
tasks
).
success
(
function
()
{
self
.
User
.
all
().
success
(
function
(
_users
)
{
self
.
Task
.
all
().
success
(
function
(
_tasks
)
{
self
.
user
=
_users
[
0
]
self
.
task
=
_tasks
[
0
]
self
.
users
=
_users
self
.
tasks
=
_tasks
self
.
user
.
getTasks
().
on
(
'success'
,
function
(
__tasks
)
{
expect
(
__tasks
).
to
.
have
.
length
(
0
)
self
.
user
.
setTasks
(
self
.
tasks
).
on
(
'success'
,
function
()
{
self
.
user
.
getTasks
().
on
(
'success'
,
function
(
_tasks
)
{
expect
(
_tasks
).
to
.
have
.
length
(
self
.
tasks
.
length
)
self
.
user
.
removeTask
(
self
.
tasks
[
0
]).
on
(
'success'
,
function
()
{
self
.
user
.
getTasks
().
on
(
'success'
,
function
(
_tasks
)
{
expect
(
_tasks
).
to
.
have
.
length
(
self
.
tasks
.
length
-
1
)
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