Better peformance for EmailAddress permissions

Following previous changeset, use EXISTS() in case of expression returning multiple rows.

closes #216

authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
changeset0d5b9482f40d
branchdefault
phasedraft
hiddenno
parent revision#c71e5bbead3d Fix performance issue on RQLExpressions using EXISTS()
child revision<not specified>
files modified by this revision
cubicweb/misc/migration/3.30.0_Any.py
cubicweb/schemas/base.py
# HG changeset patch
# User Philippe Pepiot <philippe.pepiot@logilab.fr>
# Date 1557495577 -7200
# Fri May 10 15:39:37 2019 +0200
# Node ID 0d5b9482f40d00da19d9837b171ebed9888614fb
# Parent c71e5bbead3d959b1cd08cfd2c8e440d448b15cc
Better peformance for EmailAddress permissions

Following previous changeset, use EXISTS() in case of expression returning
multiple rows.

closes #216

diff --git a/cubicweb/misc/migration/3.30.0_Any.py b/cubicweb/misc/migration/3.30.0_Any.py
@@ -0,0 +1,1 @@
1 +sync_schema_props_perms('EmailAddress')
diff --git a/cubicweb/schemas/base.py b/cubicweb/schemas/base.py
@@ -50,14 +50,14 @@
2  class EmailAddress(EntityType):
3      """an electronic mail address associated to a short alias"""
4      __permissions__ = {
5          # application that wishes public email, or use it for something else
6          # than users (eg Company, Person), should explicitly change permissions
7 -        'read':   ('managers', ERQLExpression('U use_email X')),
8 +        'read':   ('managers', ERQLExpression('EXISTS(U use_email X)')),
9          'add':    ('managers', 'users',),
10 -        'delete': ('managers', 'owners', ERQLExpression('P use_email X, U has_update_permission P')),
11 -        'update': ('managers', 'owners', ERQLExpression('P use_email X, U has_update_permission P')),
12 +        'delete': ('managers', 'owners', ERQLExpression('EXISTS(P use_email X, U has_update_permission P)')),
13 +        'update': ('managers', 'owners', ERQLExpression('EXISTS(P use_email X, U has_update_permission P)')),
14          }
15 
16      alias   = String(fulltextindexed=True, maxsize=56)
17      address = String(required=True,  fulltextindexed=True,
18                       indexed=True, unique=True, maxsize=128)