예제 #1
0
class SelectStmt(Query):

    # List of DISTINCT ON expressions, empty list for DISTINCT ALL
    distinct_clause: typing.Optional[list] = None
    # The target list
    target_list: typing.List[ResTarget] = ast.field(factory=list)
    # The FROM clause
    from_clause: typing.List[BaseRangeVar] = ast.field(factory=list)
    # The WHERE clause
    where_clause: typing.Optional[BaseExpr] = None
    # GROUP BY clauses
    group_clause: typing.Optional[typing.List[Base]] = None
    # HAVING expression
    having: typing.Optional[BaseExpr] = None
    # WINDOW window_name AS(...),
    window_clause: typing.Optional[typing.List[Base]] = None
    # List of ImplicitRow's in a VALUES query
    values: typing.Optional[typing.List[Base]] = None
    # ORDER BY clause
    sort_clause: typing.Optional[typing.List[SortBy]] = None
    # OFFSET expression
    limit_offset: typing.Optional[BaseExpr] = None
    # LIMIT expression
    limit_count: typing.Optional[BaseExpr] = None
    # FOR UPDATE clause
    locking_clause: typing.Optional[list] = None

    # Set operation type
    op: typing.Optional[str] = None
    # ALL modifier
    all: bool = False
    # Left operand of set op
    larg: typing.Optional[Query] = None
    # Right operand of set op,
    rarg: typing.Optional[Query] = None
예제 #2
0
class EdgeQLPathInfo(Base):
    """A general mixin providing EdgeQL-specific metadata on certain nodes."""

    # Ignore the below fields in AST visitor/transformer.
    __ast_meta__ = {
        'path_scope', 'path_outputs', 'path_id', 'is_distinct',
        'path_id_mask', 'path_namespace'
    }

    # The path id represented by the node.
    path_id: typing.Optional[irast.PathId] = None

    # Whether the node represents a distinct set.
    is_distinct: bool = True

    # A subset of paths necessary to perform joining.
    path_scope: typing.Set[irast.PathId] = ast.field(factory=set)

    # Map of res target names corresponding to paths.
    path_outputs: typing.Dict[
        typing.Tuple[irast.PathId, str], OutputVar
    ] = ast.field(factory=dict)

    # Map of res target names corresponding to materialized paths.
    packed_path_outputs: typing.Optional[typing.Dict[
        typing.Tuple[irast.PathId, str],
        typing.Tuple[OutputVar, bool],
    ]] = None

    path_id_mask: typing.Set[irast.PathId] = ast.field(factory=set)

    # Map of col refs corresponding to paths.
    path_namespace: typing.Dict[
        typing.Tuple[irast.PathId, str], BaseExpr
    ] = ast.field(factory=dict)
예제 #3
0
class UpdateStmt(DMLQuery):

    # The UPDATE target list
    targets: typing.List[UpdateTarget] = ast.field(factory=list)
    # WHERE clause
    where_clause: typing.Optional[BaseExpr] = None
    # optional FROM clause
    from_clause: typing.List[BaseRangeVar] = ast.field(factory=list)
예제 #4
0
파일: ast.py 프로젝트: stjordanis/edgedb
class EdgeQLPathInfo(Base):
    """A general mixin providing EdgeQL-specific metadata on certain nodes."""

    # Ignore the below fields in AST visitor/transformer.
    __ast_meta__ = {
        'path_scope',
        'path_outputs',
        'path_id',
        'is_distinct',
        'path_id_mask',
        'path_namespace',
        'packed_path_outputs',
        'packed_path_namespace',
    }

    # The path id represented by the node.
    path_id: typing.Optional[irast.PathId] = None

    # Whether the node represents a distinct set.
    is_distinct: bool = True

    # A subset of paths necessary to perform joining.
    path_scope: typing.Set[irast.PathId] = ast.field(factory=set)

    # Map of res target names corresponding to paths.
    path_outputs: typing.Dict[typing.Tuple[irast.PathId, str],
                              OutputVar] = ast.field(factory=dict)

    # Map of res target names corresponding to materialized paths.
    packed_path_outputs: typing.Optional[typing.Dict[typing.Tuple[irast.PathId,
                                                                  str],
                                                     OutputVar, ]] = None

    def get_path_outputs(
        self, flavor: str
    ) -> typing.Dict[typing.Tuple[irast.PathId, str], OutputVar]:
        if flavor == 'packed':
            if self.packed_path_outputs is None:
                self.packed_path_outputs = {}
            return self.packed_path_outputs
        elif flavor == 'normal':
            return self.path_outputs
        else:
            raise AssertionError(f'unexpected flavor "{flavor}"')

    path_id_mask: typing.Set[irast.PathId] = ast.field(factory=set)

    # Map of col refs corresponding to paths.
    path_namespace: typing.Dict[typing.Tuple[irast.PathId, str],
                                BaseExpr] = ast.field(factory=dict)

    # Same, but for packed.
    packed_path_namespace: typing.Optional[typing.Dict[typing.Tuple[
        irast.PathId, str], BaseExpr, ]] = None
예제 #5
0
파일: ast.py 프로젝트: stjordanis/edgedb
class Query(ReturningQuery):
    """Generic superclass representing a query."""

    # Ignore the below fields in AST visitor/transformer.
    __ast_meta__ = {
        'path_rvar_map', 'path_packed_rvar_map', 'view_path_id_map',
        'argnames', 'nullable'
    }

    view_path_id_map: typing.Dict[irast.PathId,
                                  irast.PathId] = ast.field(factory=dict)
    # Map of RangeVars corresponding to paths.
    path_rvar_map: typing.Dict[typing.Tuple[irast.PathId, str],
                               PathRangeVar] = ast.field(factory=dict)
    # Map of materialized RangeVars corresponding to paths.
    path_packed_rvar_map: typing.Optional[typing.Dict[typing.Tuple[
        irast.PathId, str], PathRangeVar, ]] = None

    argnames: typing.Optional[typing.Dict[str, Param]] = None

    ctes: typing.Optional[typing.List[CommonTableExpr]] = None

    def get_rvar_map(
        self, flavor: str
    ) -> typing.Dict[typing.Tuple[irast.PathId, str], PathRangeVar]:
        if flavor == 'packed':
            if self.path_packed_rvar_map is None:
                self.path_packed_rvar_map = {}
            return self.path_packed_rvar_map
        elif flavor == 'normal':
            return self.path_rvar_map
        else:
            raise AssertionError(f'unexpected flavor "{flavor}"')

    def maybe_get_rvar_map(
        self, flavor: str
    ) -> typing.Optional[typing.Dict[typing.Tuple[irast.PathId, str],
                                     PathRangeVar]]:
        if flavor == 'packed':
            return self.path_packed_rvar_map
        elif flavor == 'normal':
            return self.path_rvar_map
        else:
            raise AssertionError(f'unexpected flavor "{flavor}"')

    @property
    def ser_safe(self):
        return all(t.ser_safe for t in self.target_list)

    def append_cte(self, cte: CommonTableExpr) -> None:
        if self.ctes is None:
            self.ctes = []
        self.ctes.append(cte)
예제 #6
0
 class Node(Base):
     field_list: list = ast.field(factory=list)
     field_typing_list: typing.List[Base] = ast.field(factory=list)
     field_typing_tuple: typing.Tuple[Base, ...] = ()
     field_typing_union: typing.Union[str, bytes]
     field_typing_union_list: typing.List[typing.Union[
         str, bytes]] = ast.field(factory=list)
     field_typing_str: str
     field_typing_optional_str: typing.Optional[str]
     field_typing_mapping: typing.Dict[int,
                                       str] = ast.field(factory=dict)
     field_typing_mapping_opt_key: \
         typing.Dict[
             typing.Optional[int], str] = ast.field(factory=dict)
예제 #7
0
파일: ast.py 프로젝트: stjordanis/edgedb
class GroupStmt(FilteredStmt):
    subject: Set = EmptySet()  # type: ignore
    using: typing.Dict[str, typing.Tuple[Set,
                                         qltypes.Cardinality]] = (ast.field(
                                             factory=dict))
    by: typing.List[qlast.GroupingElement]
    result: Set = EmptySet()  # type: ignore
    group_binding: Set = EmptySet()  # type: ignore
    grouping_binding: typing.Optional[Set] = None
    orderby: typing.Optional[typing.List[SortExpr]] = None
    # Optimization information
    group_aggregate_sets: typing.Dict[typing.Optional[Set],
                                      typing.FrozenSet[PathId]] = ast.field(
                                          factory=dict)
예제 #8
0
class DMLQuery(Query):
    """Generic superclass for INSERT/UPDATE/DELETE statements."""

    # Target relation to perform the operation on.
    relation: typing.Optional[PathRangeVar] = None
    # List of expressions returned
    returning_list: typing.List[ResTarget] = ast.field(factory=list)

    @property
    def target_list(self):
        return self.returning_list
예제 #9
0
class Options(Base):

    options: typing.Dict[str, OptionValue] = ast.field(factory=dict)

    def get_flag(self, k: str) -> Flag:
        try:
            flag = self[k]
        except KeyError:
            return Flag(name=k, val=False)
        else:
            assert isinstance(flag, Flag)
            return flag

    def __getitem__(self, k: str) -> OptionValue:
        return self.options[k]

    def __iter__(self) -> typing.Iterator[str]:
        return iter(self.options)

    def __len__(self) -> int:
        return len(self.options)
예제 #10
0
class DeleteStmt(DMLQuery):
    # WHERE clause
    where_clause: typing.Optional[BaseExpr] = None
    # optional USING clause
    using_clause: typing.List[BaseRangeVar] = ast.field(factory=list)
예제 #11
0
class ReturningQuery(BaseRelation):

    target_list: typing.List[ResTarget] = ast.field(factory=list)
예제 #12
0
class DDLOperation(DDL):
    __abstract_node__ = True
    commands: typing.List[DDLOperation] = ast.field(factory=list)
예제 #13
0
class FunctionCall(Expr):
    func: typing.Union[tuple, str]
    args: typing.List[Expr] = ast.field(factory=list)
    kwargs: typing.Dict[str, Expr] = ast.field(factory=dict)
    window: typing.Optional[WindowSpec] = None
예제 #14
0
class CallableObjectCommand(ObjectDDL):

    __abstract_node__ = True
    params: typing.List[FuncParam] = ast.field(factory=list)