Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
fb5c0e60a615
Commit
88ecd5f8
authored
Feb 08, 2012
by
Florent Cayré
Browse files
[entity] fix crash when using cw_instantiate with empty related entity list; closes #2094462
--HG-- branch : stable
parent
ce9c6ae03c2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
entity.py
View file @
fb5c0e60
...
...
@@ -481,7 +481,9 @@ class Entity(AppObject):
assert
eschema
.
has_relation
(
attr
,
role
),
'%s %s not found on %s'
%
(
attr
,
role
,
eschema
)
rschema
=
eschema
.
subjrels
[
attr
]
if
role
==
'subject'
else
eschema
.
objrels
[
attr
]
if
not
rschema
.
final
and
isinstance
(
value
,
(
tuple
,
list
,
set
,
frozenset
)):
if
len
(
value
)
==
1
:
if
len
(
value
)
==
0
:
continue
# avoid crash with empty IN clause
elif
len
(
value
)
==
1
:
value
=
iter
(
value
).
next
()
else
:
# prepare IN clause
...
...
test/unittest_entity.py
View file @
fb5c0e60
...
...
@@ -143,6 +143,8 @@ class EntityTC(CubicWebTC):
req
=
self
.
request
()
p1
=
req
.
create_entity
(
'Personne'
,
nom
=
u
'di'
)
p2
=
req
.
create_entity
(
'Personne'
,
nom
=
u
'mascio'
)
t
=
req
.
create_entity
(
'Tag'
,
name
=
u
't0'
,
tags
=
[])
self
.
assertItemsEqual
(
t
.
tags
,
[])
t
=
req
.
create_entity
(
'Tag'
,
name
=
u
't1'
,
tags
=
p1
)
self
.
assertItemsEqual
(
t
.
tags
,
[
p1
])
t
=
req
.
create_entity
(
'Tag'
,
name
=
u
't2'
,
tags
=
p1
.
eid
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment