def _apply_field_ast( self, schema: s_schema.Schema, context: sd.CommandContext, node: qlast.DDLOperation, op: sd.AlterObjectProperty, ) -> None: if op.property == 'default': if op.new_value: assert isinstance(op.new_value, list) op.new_value = op.new_value[0] super()._apply_field_ast(schema, context, node, op) elif op.property == 'bases': enum_values = self.get_attribute_value('enum_values') if enum_values: node.bases = [ qlast.TypeName( maintype=qlast.ObjectRef(name='enum'), subtypes=[ qlast.TypeExprLiteral( val=qlast.StringConstant.from_python(v) ) for v in enum_values ] ) ] else: super()._apply_field_ast(schema, context, node, op) else: super()._apply_field_ast(schema, context, node, op)
def _apply_field_ast(self, schema, context, node, op): if op.property == 'default': if op.new_value: op.new_value = op.new_value[0] super()._apply_field_ast(schema, context, node, op) elif op.property == 'bases': enum_values = self.get_attribute_value('enum_values') if enum_values: node.bases = [ qlast.TypeName( maintype=qlast.ObjectRef(name='enum'), subtypes=[ qlast.TypeExprLiteral( val=qlast.BaseConstant.from_python(v)) for v in enum_values ]) ] else: super()._apply_field_ast(schema, context, node, op) else: super()._apply_field_ast(schema, context, node, op)
def reduce_BaseStringConstant(self, *kids): self.val = qlast.TypeExprLiteral(val=kids[0].val, )
def reduce_BaseStringConstant(self, *kids): # TODO: Raise a DeprecationWarning once we have facility for that. self.val = qlast.TypeExprLiteral(val=kids[0].val, )