コード例 #1
0
ファイル: scalars.py プロジェクト: LeonardAukea/edgedb
    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)
コード例 #2
0
ファイル: scalars.py プロジェクト: simhaonline/edgedb
    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)
コード例 #3
0
ファイル: expressions.py プロジェクト: doytsujin/edgedb
 def reduce_BaseStringConstant(self, *kids):
     self.val = qlast.TypeExprLiteral(val=kids[0].val, )
コード例 #4
0
 def reduce_BaseStringConstant(self, *kids):
     # TODO: Raise a DeprecationWarning once we have facility for that.
     self.val = qlast.TypeExprLiteral(val=kids[0].val, )