Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
07c828468ccb
Commit
6cff40d5
authored
Feb 11, 2016
by
Julien Cristau
Browse files
WIP try to handle constraint violations involving more than one column
Related to #10673348
parent
e3f28ad6f926
Pipeline
#92026
failed with stages
in 43 minutes and 13 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
cubicweb/entities/adapters.py
View file @
07c82846
...
...
@@ -626,11 +626,28 @@ class IUserFriendlyCheckConstraint(IUserFriendlyError):
break
else
:
assert
0
key
=
rschema
.
type
+
"-subject"
# use .get since a constraint may be associated to an attribute that isn't edited (e.g.
# constraint between two attributes). This should be the purpose of an api rework at some
# point, we currently rely on the fact that such constraint will provide a dedicated user
# message not relying on the `value` argument
value
=
self
.
entity
.
cw_edited
.
get
(
rschema
.
type
)
msg
,
args
=
constraint
.
failed_message
(
key
,
value
,
self
.
entity
)
rtype
=
rschema
.
type
# if the constraint involves more than one column, try to find one which was modified
if
rtype
not
in
self
.
entity
.
cw_edited
:
from
yams.constraints
import
Attribute
if
constraint
.
type
()
==
"BoundaryConstraint"
:
if
(
isinstance
(
constraint
.
boundary
,
Attribute
)
and
constraint
.
boundary
.
attr
in
self
.
entity
.
cw_edited
):
rtype
=
constraint
.
boundary
.
attr
elif
constraint
.
type
()
==
"IntervalBoundConstraint"
:
if
(
isinstance
(
constraint
.
minvalue
,
Attribute
)
and
constraint
.
minvalue
.
attr
in
self
.
entity
.
cw_edited
):
rtype
=
constraint
.
minvalue
.
attr
elif
(
isinstance
(
constraint
.
maxvalue
,
Attribute
)
and
constraint
.
maxvalue
.
attr
in
self
.
entity
.
cw_edited
):
rtype
=
constraint
.
maxvalue
.
attr
key
=
rtype
+
"-subject"
msg
,
args
=
constraint
.
failed_message
(
key
,
self
.
entity
,
rtype
)
raise
ValidationError
(
self
.
entity
.
eid
,
{
key
:
msg
},
args
)
Write
Preview
Markdown
is supported
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