Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into darker
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen committed Mar 26, 2024
2 parents 1a7cd4a + b0e4022 commit c69debf
Show file tree
Hide file tree
Showing 36 changed files with 630 additions and 620 deletions.
31 changes: 0 additions & 31 deletions docs/glossary.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/reference/admin/branches.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Branch


This section describes the administrative commands pertaining to
:ref:`branchs <ref_datamodel_branches>`.
:ref:`branches <ref_datamodel_branches>`.


Create empty branch
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/edgeql/eval.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ A nested query is called a *subquery*. Here, the phrase

A query is evaluated recursively using the following procedure:

1. Make a list of :term:`simple paths <simple path>` appearing directly the
query. For every path in the list, find all paths which begin with the
same set reference and treat their longest common prefix as an equivalent
set reference.
1. Make a list of simple paths (i.e., paths that begin with a set reference)
appearing directly the query. For every path in the list, find all paths
which begin with the same set reference and treat their longest common
prefix as an equivalent set reference.

Example:

Expand Down
7 changes: 5 additions & 2 deletions edb/edgeql/compiler/casts.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ def compile_cast(
'"any" types or abstract scalars.',
span=span)

if isinstance(ir_expr, irast.EmptySet):
if (
isinstance(ir_expr, irast.Set)
and isinstance(ir_expr.expr, irast.EmptySet)
):
# For the common case of casting an empty set, we simply
# generate a new EmptySet node of the requested type.
# generate a new empty set node of the requested type.
return setgen.new_empty_set(
stype=new_stype,
alias=ir_expr.path_id.target_name_hint.name,
Expand Down
6 changes: 3 additions & 3 deletions edb/edgeql/compiler/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ def _validate_config_object(
ctx: context.ContextLevel) -> None:

for element, _ in expr.shape:
assert element.rptr is not None
if element.rptr.ptrref.shortname.name == 'id':
assert isinstance(element.expr, irast.Pointer)
if element.expr.ptrref.shortname.name == 'id':
continue

ptr = typegen.ptrcls_from_ptrref(
element.rptr.ptrref.real_material_ptr,
element.expr.ptrref.real_material_ptr,
ctx=ctx,
)
if isinstance(ptr, s_pointers.Pointer):
Expand Down
20 changes: 9 additions & 11 deletions edb/edgeql/compiler/conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def _compile_conflict_select(
assert isinstance(select_ir, irast.Set)

# If we have an empty set, remake it with the right type
if isinstance(select_ir, irast.EmptySet):
if isinstance(select_ir.expr, irast.EmptySet):
select_ir = setgen.new_empty_set(stype=subject_typ, ctx=ctx)

return select_ir, always_check, from_parent
Expand Down Expand Up @@ -494,20 +494,20 @@ def compile_insert_unless_conflict_on(

# We accept a property, link, or a list of them in the form of a
# tuple.
if cspec_res.rptr is None and isinstance(cspec_res.expr, irast.Tuple):
if isinstance(cspec_res.expr, irast.Tuple):
cspec_args = [elem.val for elem in cspec_res.expr.elements]
else:
cspec_args = [cspec_res]

for cspec_arg in cspec_args:
if not cspec_arg.rptr:
if not isinstance(cspec_arg.expr, irast.Pointer):
raise errors.QueryError(
'UNLESS CONFLICT argument must be a property, link, '
'or tuple of properties and links',
span=constraint_spec.span,
)

if cspec_arg.rptr.source.path_id != stmt.subject.path_id:
if cspec_arg.expr.source.path_id != stmt.subject.path_id:
raise errors.QueryError(
'UNLESS CONFLICT argument must be a property of the '
'type being inserted',
Expand All @@ -519,9 +519,9 @@ def compile_insert_unless_conflict_on(
ptrs = []
exclusive_constr = schema.get('std::exclusive', type=s_constr.Constraint)
for cspec_arg in cspec_args:
assert cspec_arg.rptr is not None
assert isinstance(cspec_arg.expr, irast.Pointer)
schema, ptr = (
typeutils.ptrcls_from_ptrref(cspec_arg.rptr.ptrref, schema=schema))
typeutils.ptrcls_from_ptrref(cspec_arg.expr.ptrref, schema=schema))
if not isinstance(ptr, s_pointers.Pointer):
raise errors.QueryError(
'UNLESS CONFLICT argument must be a property, link, '
Expand Down Expand Up @@ -593,8 +593,7 @@ def compile_insert_unless_conflict_on(

def _has_explicit_id_write(stmt: irast.MutatingStmt) -> bool:
for elem, _ in stmt.subject.shape:
assert elem.rptr is not None
if elem.rptr.ptrref.shortname.name == 'id':
if elem.expr.ptrref.shortname.name == 'id':
return elem.span is not None
return False

Expand Down Expand Up @@ -656,9 +655,8 @@ def _compile_inheritance_conflict_selects(

shape_ptrs = set()
for elem, op in stmt.subject.shape:
assert elem.rptr is not None
if op != qlast.ShapeOp.MATERIALIZE:
shape_ptrs.add(elem.rptr.ptrref.shortname.name)
shape_ptrs.add(elem.expr.ptrref.shortname.name)

# This is a little silly, but for *this* we need to do one per
# constraint (so that we can properly identify which constraint
Expand Down Expand Up @@ -708,7 +706,7 @@ def _compile_inheritance_conflict_selects(
constrs=p,
obj_constrs=o,
span=stmt.span, ctx=ctx)
if isinstance(select_ir, irast.EmptySet):
if isinstance(select_ir.expr, irast.EmptySet):
continue
cnstr_ref = irast.ConstraintRef(id=cnstr.id)
clauses.append(
Expand Down
8 changes: 4 additions & 4 deletions edb/edgeql/compiler/eta_expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ def needs_eta_expansion(
# an important optimization to support, but our expansion can generate
# this idiom, so on principle I wanted to support it.
if (
isinstance(ir.rptr, irast.TupleIndirectionPointer)
and isinstance(ir.rptr.source.expr, irast.Tuple)
isinstance(ir.expr, irast.TupleIndirectionPointer)
and isinstance(ir.expr.source.expr, irast.Tuple)
):
name = ir.rptr.ptrref.shortname.name
els = [x for x in ir.rptr.source.expr.elements if x.name == name]
name = ir.expr.ptrref.shortname.name
els = [x for x in ir.expr.source.expr.elements if x.name == name]
if len(els) == 1:
return needs_eta_expansion(els[0].val, ctx=ctx)

Expand Down
4 changes: 2 additions & 2 deletions edb/edgeql/compiler/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def _compile_dml_ifelse(

els: list[qlast.Expr] = []

if not isinstance(irutils.unwrap_set(if_ir), irast.EmptySet):
if not isinstance(irutils.unwrap_set(if_ir).expr, irast.EmptySet):
if_b = qlast.ForQuery(
iterator_alias=ctx.aliases.get('_ifelse_true_dummy'),
iterator=qlast.SelectQuery(
Expand All @@ -484,7 +484,7 @@ def _compile_dml_ifelse(
)
els.append(if_b)

if not isinstance(irutils.unwrap_set(else_ir), irast.EmptySet):
if not isinstance(irutils.unwrap_set(else_ir).expr, irast.EmptySet):
else_b = qlast.ForQuery(
iterator_alias=ctx.aliases.get('_ifelse_false_dummy'),
iterator=qlast.SelectQuery(
Expand Down
25 changes: 14 additions & 11 deletions edb/edgeql/compiler/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def visit_Set(self, node: irast.Set, skip_rptr: bool=False) -> None:
# because the bodies are executed one at a time, and so the
# semi-join deduplication doesn't work.
is_semijoin = (
node.rptr
isinstance(node.expr, irast.Pointer)
and node.path_id.is_objtype_path()
and not self.scope_tree.is_visible(node.rptr.source.path_id)
and not self.scope_tree.is_visible(node.expr.source.path_id)
)

old = self.aggregate
Expand All @@ -129,17 +129,20 @@ def visit_Set(self, node: irast.Set, skip_rptr: bool=False) -> None:

self.visit(node.shape)

# XXX: old_expr
if not node.old_expr and node.rptr:
self.visit(node.rptr.source)
elif node.rptr:
if node.rptr.source.path_id not in self.seen:
self.seen[node.rptr.source.path_id] = False
if isinstance(node.expr, irast.Pointer):
sub_expr = node.expr.expr
if not sub_expr:
self.visit(node.expr.source)
else:
if node.expr.source.path_id not in self.seen:
self.seen[node.expr.source.path_id] = False
else:
sub_expr = node.expr

if isinstance(node.expr, irast.Call):
self.process_call(node.expr, node)
if isinstance(sub_expr, irast.Call):
self.process_call(sub_expr, node)
else:
self.visit(node.old_expr)
self.visit(sub_expr)

self.aggregate = old
self.scope_tree = old_scope
Expand Down
Loading

0 comments on commit c69debf

Please sign in to comment.