How to use the edgedb.lang.ir.ast.Conjunction function in edgedb

To help you get started, we’ve selected a few edgedb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github edgedb / edgedb / edgedb / lang / edgeql / compiler / pathmerger.py View on Github external
if len(left_set.conjunction.paths) == 1:
                    first_conj = next(iter(left_set.conjunction.paths))
                    if isinstance(first_conj, irast.Disjunction):
                        left_set.disjunction = first_conj
                        left_set.conjunction = irast.Conjunction()

        if isinstance(left, irast.EntitySet):
            return left
        elif isinstance(right, irast.EntitySet):
            return right
        else:
            return left_link

    else:
        result = irast.Conjunction(paths=frozenset({left, right}))

    return result
github edgedb / edgedb / edgedb / lang / edgeql / compiler.py View on Github external
steps=[
                    pathspec.expr
                ]
            )

            targetexpr = self._process_path(context, tpath,
                                            path_tip=graph.optarget)

            if isinstance(value, qlast.ConstantNode):
                v = self._process_constant(context, value)
            else:
                with context():
                    context.current.local_link_source = graph.optarget
                    v = self._process_expr(context, value)

                paths = irast.Conjunction(
                            paths=frozenset((v, graph.optarget)))
                self.flatten_and_unify_path_combination(
                    paths, deep=True, merge_filters=True)
                self._check_update_expr(graph.optarget, targetexpr, v)

            ref = irast.UpdateExpr(expr=targetexpr, value=v)
            refs.append(ref)

        return refs
github edgedb / edgedb / edgedb / lang / ir / transformer.py View on Github external
def entityref_to_record(self, expr, schema, *, pathspec=None,
                            prefixes=None, select_linkprops=False,
                            _visited_records=None, _recurse=True):
        """Convert an EntitySet node into an Record referencing eager-pointers of EntitySet concept
        """

        if not isinstance(expr, irast.PathCombination):
            expr = irast.Conjunction(paths=frozenset((expr,)))

        p = next(iter(expr.paths))

        if not isinstance(p, irast.EntitySet):
            return expr

        path_rlink = None

        if _visited_records is None:
            _visited_records = {}

            if p.rlink is not None:
                path_rlink = p.rlink

        recurse_links = None
        recurse_metarefs = ['id', 'name']
github edgedb / edgedb / edgedb / lang / edgeql / compiler / pathmerger.py View on Github external
def intersect_with_disjunction(context, disjunction, path):
    result = irast.Conjunction(paths=frozenset((disjunction, path)))
    return result
github edgedb / edgedb / edgedb / lang / ir / transformer.py View on Github external
else:
                    self.merge_paths(expr.ref.source)
                expr = irast.InlinePropFilter(expr=expr.ref.propfilter, ref=expr.ref)
            else:
                self.merge_paths(expr.expr)

        elif isinstance(expr, irast.BinOp):
            left = self.merge_paths(expr.left)
            right = self.merge_paths(expr.right)

            weak_op = self.is_weak_op(expr.op)

            if weak_op:
                combination = irast.Disjunction
            else:
                combination = irast.Conjunction

            paths = set()
            for operand in (left, right):
                if isinstance(operand, (irast.InlineFilter, irast.AtomicRefSimple)):
                    paths.add(operand.ref)
                else:
                    paths.add(operand)

            e = combination(paths=frozenset(paths))
            merge_filters = self.context.current.location != 'generator' or weak_op
            if merge_filters:
                merge_filters = expr.op
            self.flatten_and_unify_path_combination(e, deep=False, merge_filters=merge_filters)

            if len(e.paths) > 1:
                expr = irast.BinOp(left=left, op=expr.op, right=right, aggregates=expr.aggregates)
github edgedb / edgedb / edgedb / lang / ir / transformer.py View on Github external
def intersect_disjunction_with_conjunction(self, disjunction, conjunction):
        if disjunction.paths and conjunction.paths:
            return irast.Disjunction(paths=frozenset({disjunction, conjunction}))
        elif conjunction.paths:
            return conjunction
        elif disjunction.paths:
            return irast.Conjunction(paths=frozenset({disjunction}))
        else:
            return irast.Conjunction()
github edgedb / edgedb / edgedb / lang / ir / transformer.py View on Github external
def conjunctions_from_miniterms(self, terms, variables):
        paths = set()

        for term in terms:
            conjpaths = [variables[i] for i, bit in enumerate(term) if bit]
            if len(conjpaths) > 1:
                paths.add(irast.Conjunction(paths=frozenset(conjpaths)))
            else:
                paths.add(conjpaths[0])
        return paths
github edgedb / edgedb / edgedb / lang / ir / transformer.py View on Github external
def add_paths(self, left, right, merge_filters=False):
        if isinstance(left, (irast.EntityLink, irast.EntitySet)):
            if isinstance(right, (irast.EntityLink, irast.EntitySet)):
                # Both operands are sets -- simply merge them
                result = self.add_sets(left, right, merge_filters)

            elif isinstance(right, irast.Disjunction):
                result = self.add_to_disjunction(right, left, merge_filters)

            elif isinstance(right, irast.Conjunction):
                result = self.add_to_conjunction(right, left, merge_filters)

        elif isinstance(left, irast.Disjunction):
            if isinstance(right, (irast.EntityLink, irast.EntitySet)):
                result = self.add_to_disjunction(left, right, merge_filters)

            elif isinstance(right, irast.Disjunction):
                result = self.add_disjunctions(left, right, merge_filters)

            elif isinstance(right, irast.Conjunction):
                result = self.add_conjunction_to_disjunction(left, right)

        elif isinstance(left, irast.Conjunction):
            if isinstance(right, (irast.EntityLink, irast.EntitySet)):
                result = self.add_to_conjunction(left, right, merge_filters)
github edgedb / edgedb / edgedb / lang / ir / transformer.py View on Github external
if not link_singular or recurse_link is not None:
                lref = self.copy_path(ref, connect_to_origin=True)
                lref.reference = ref
            else:
                lref = ref

            if recurse_link is not None:
                lref.rlink = None

            if prefixes and full_path_id in prefixes and lref is ref:
                targetstep = prefixes[full_path_id]
                targetstep = next(iter(targetstep))
                link_node = targetstep.rlink
                reusing_target = True
            else:
                targetstep = irast.EntitySet(conjunction=irast.Conjunction(),
                                                disjunction=irast.Disjunction(),
                                                users={self.context.current.location},
                                                concept=target_proto, id=full_path_id)

                link_node = irast.EntityLink(source=lref, target=targetstep,
                                                link_proto=link_proto,
                                                direction=link_direction,
                                                users={'selector'})

                targetstep.rlink = link_node
                reusing_target = False

            if recurse_spec.trigger is not None:
                link_node.pathspec_trigger = recurse_spec.trigger

            if not link.atomic():