check for usage of optional on final relation
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 15 Mar 2010 18:21:35 +0100
changeset 506 132d783e5153
parent 505 47e970bfc0e7
child 507 3d59f6b1cbb9
check for usage of optional on final relation
stcheck.py
--- a/stcheck.py	Mon Mar 15 18:21:21 2010 +0100
+++ b/stcheck.py	Mon Mar 15 18:21:35 2010 +0100
@@ -280,8 +280,15 @@
                 #assert isinstance(rhs.children[0], Constant)
                 #assert rhs.operator == 'IS', rhs.operator
                 #assert rhs.children[0].type == None
-        elif not relation.r_type in self.schema:
-            errors.append('unknown relation `%s`' % relation.r_type)
+        else:
+            try:
+                rschema = self.schema.rschema(relation.r_type)
+            except KeyError:
+                errors.append('unknown relation `%s`' % relation.r_type)
+            else:
+                if relation.optional and rschema.final:
+                    errors.append("shouldn't use optional on final relation `%s`"
+                                  % relation.r_type)
         try:
             vargraph = relation.stmt.vargraph
             rhsvarname = relation.children[1].children[0].variable.name