def canonicalize_alter_from_external_ref( self, schema: s_schema.Schema, context: sd.CommandContext, ) -> None: if ( not self.get_attribute_value('abstract') and (subjectexpr := self.get_attribute_value('subjectexpr')) is not None ): # To compute the new name, we construct an AST of the # constraint, since that is the infrastructure we have for # computing the classname. name = sn.shortname_from_fullname(self.classname) assert isinstance(name, sn.QualName), "expected qualified name" ast = qlast.CreateConcreteConstraint( name=qlast.ObjectRef(name=name.name, module=name.module), subjectexpr=subjectexpr.qlast, args=[], ) quals = sn.quals_from_fullname(self.classname) new_name = self._classname_from_ast_and_referrer( schema, sn.QualName.from_string(quals[0]), ast, context) if new_name == self.classname: return rename = self.scls.init_delta_command( schema, sd.RenameObject, new_name=new_name) rename.set_attribute_value( 'name', value=new_name, orig_value=self.classname) self.add(rename)
def reduce_CreateConstraint(self, *kids): r"""%reduce CONSTRAINT \ NodeName OptConcreteConstraintArgList OptOnExpr""" self.val = qlast.CreateConcreteConstraint( name=kids[1].val, args=kids[2].val, subjectexpr=kids[3].val, )
def reduce_CreateDelegatedConstraint(self, *kids): r"""%reduce DELEGATED CONSTRAINT \ NodeName OptConcreteConstraintArgList OptOnExpr""" self.val = qlast.CreateConcreteConstraint( delegated=True, name=kids[2].val, args=kids[3].val, subjectexpr=kids[4].val, )
def reduce_CreateConstraint(self, *kids): r"""%reduce CREATE OptDelegated CONSTRAINT \ NodeName OptConcreteConstraintArgList OptOnExpr \ OptCreateCommandsBlock""" self.val = qlast.CreateConcreteConstraint( is_abstract=kids[1].val, name=kids[3].val, args=kids[4].val, subjectexpr=kids[5].val, commands=kids[6].val, )
def reduce_CreateDelegatedConstraint(self, *kids): r"""%reduce DELEGATED CONSTRAINT \ NodeName OptConcreteConstraintArgList OptOnExpr \ CreateSDLCommandsBlock""" self.val = qlast.CreateConcreteConstraint( is_abstract=True, name=kids[2].val, args=kids[3].val, subjectexpr=kids[4].val, commands=kids[5].val, )