[CWEP002] Account for attribute formula in schema bootstrap
authorDenis Laxalde <denis.laxalde@logilab.fr>
Mon, 16 Jun 2014 10:08:32 +0200
changeset 9965 a8769b752299
parent 9964 f4a3ee05cf9d
child 9966 6c2d57d1b6de
[CWEP002] Account for attribute formula in schema bootstrap This isn't enough to have computed attribute support, it is only in order not to crash when yams 0.40 is used. Related to #3546717.
hooks/syncschema.py
schemas/bootstrap.py
server/test/unittest_repository.py
server/test/unittest_schemaserial.py
test/unittest_schema.py
--- a/hooks/syncschema.py	Thu Aug 28 07:44:29 2014 +0200
+++ b/hooks/syncschema.py	Mon Jun 16 10:08:32 2014 +0200
@@ -448,6 +448,7 @@
             default = default.unzpickle()
         props = {'default': default,
                  'indexed': entity.indexed,
+                 'formula': entity.formula,
                  'fulltextindexed': entity.fulltextindexed,
                  'internationalizable': entity.internationalizable}
         # update the in-memory schema first
--- a/schemas/bootstrap.py	Thu Aug 28 07:44:29 2014 +0200
+++ b/schemas/bootstrap.py	Mon Jun 16 10:08:32 2014 +0200
@@ -90,6 +90,7 @@
                          description=_('subject/object cardinality'))
     ordernum = Int(description=('control subject entity\'s relations order'), default=0)
 
+    formula = String(maxsize=2048)
     indexed = Boolean(description=_('create an index for quick search on this attribute'))
     fulltextindexed = Boolean(description=_('index this attribute\'s value in the plain text index'))
     internationalizable = Boolean(description=_('is this attribute\'s value translatable'))
--- a/server/test/unittest_repository.py	Thu Aug 28 07:44:29 2014 +0200
+++ b/server/test/unittest_repository.py	Mon Jun 16 10:08:32 2014 +0200
@@ -280,7 +280,7 @@
         self.assertListEqual(['relation_type',
                               'from_entity', 'to_entity',
                               'constrained_by',
-                              'cardinality', 'ordernum',
+                              'cardinality', 'ordernum', 'formula',
                               'indexed', 'fulltextindexed', 'internationalizable',
                               'defaultval', 'extra_props',
                               'description', 'description_format'],
--- a/server/test/unittest_schemaserial.py	Thu Aug 28 07:44:29 2014 +0200
+++ b/server/test/unittest_schemaserial.py	Mon Jun 16 10:08:32 2014 +0200
@@ -222,7 +222,7 @@
               'inlined': False}),
 
             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
-             'X description %(description)s,X fulltextindexed %(fulltextindexed)s,'
+             'X description %(description)s,X formula %(formula)s,X fulltextindexed %(fulltextindexed)s,'
              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,'
              'X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
@@ -235,6 +235,7 @@
               'ordernum': 5,
               'defaultval': None,
               'indexed': False,
+              'formula': None,
               'cardinality': u'?1'}),
             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
@@ -248,7 +249,7 @@
               'value': u"u'?1', u'11'"}),
 
             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
-             'X description %(description)s,X fulltextindexed %(fulltextindexed)s,'
+             'X description %(description)s,X formula %(formula)s,X fulltextindexed %(fulltextindexed)s,'
              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE '
              'WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
@@ -261,6 +262,7 @@
               'ordernum': 5,
               'defaultval': None,
               'indexed': False,
+              'formula': None,
               'cardinality': u'?1'}),
             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
@@ -273,7 +275,7 @@
               'ct': u'StaticVocabularyConstraint_eid',
               'value': (u"u'?*', u'1*', u'+*', u'**', u'?+', u'1+', u'++', u'*+', u'?1', "
                         "u'11', u'+1', u'*1', u'??', u'1?', u'+?', u'*?'")})],
-                             list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)))
+              list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)))
 
     def test_rschema2rql_custom_type(self):
         expected = [('INSERT CWRType X: X description %(description)s,X final %(final)s,'
@@ -287,13 +289,14 @@
                       'symmetric': False}),
                      ('INSERT CWAttribute X: X cardinality %(cardinality)s,'
                       'X defaultval %(defaultval)s,X description %(description)s,'
-                      'X extra_props %(extra_props)s,X indexed %(indexed)s,'
+                      'X extra_props %(extra_props)s,X formula %(formula)s,X indexed %(indexed)s,'
                       'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,'
                       'X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
                       {'cardinality': u'?1',
                        'defaultval': None,
                        'description': u'',
                        'extra_props': '{"jungle_speed": 42}',
+                       'formula': None,
                        'indexed': False,
                        'oe': None,
                        'ordernum': 4,
@@ -313,7 +316,7 @@
     def test_rdef2rql(self):
         self.assertListEqual([
             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
-             'X description %(description)s,X fulltextindexed %(fulltextindexed)s,'
+             'X description %(description)s,X formula %(formula)s,X fulltextindexed %(fulltextindexed)s,'
              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,'
              'X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
@@ -326,6 +329,7 @@
               'ordernum': 3,
               'defaultval': Binary('text/plain'),
               'indexed': False,
+              'formula': None,
               'cardinality': u'?1'}),
             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
--- a/test/unittest_schema.py	Thu Aug 28 07:44:29 2014 +0200
+++ b/test/unittest_schema.py	Mon Jun 16 10:08:32 2014 +0200
@@ -193,7 +193,7 @@
 
                               'ecrit_par', 'eid', 'end_timestamp', 'evaluee', 'expression', 'exprtype', 'extra_props',
 
-                              'fabrique_par', 'final', 'firstname', 'for_user', 'fournit',
+                              'fabrique_par', 'final', 'firstname', 'for_user', 'formula', 'fournit',
                               'from_entity', 'from_state', 'fulltext_container', 'fulltextindexed',
 
                               'has_group_permission', 'has_text',