How to use the pglast.enums function in pglast

To help you get started, we’ve selected a few pglast 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 lelit / pglast / pglast / printers / dml.py View on Github external
def a_expr(node, output):
    aek = enums.A_Expr_Kind

    if node.kind == aek.AEXPR_OP:
        with output.expression():
            # lexpr is optional because these are valid: -(1+1), +(1+1), ~(1+1)
            if node.lexpr is not Missing:
                if node.lexpr.node_tag == 'A_Expr':
                    with output.expression():
                        output.print_node(node.lexpr)
                else:
                    output.print_node(node.lexpr)
                output.write(' ')
            if isinstance(node.name, List) and len(node.name) > 1:
                output.write('OPERATOR(')
                output.print_symbol(node.name)
                output.write(') ')
            else:
github lelit / pglast / pglast / printers / dml.py View on Github external
def sort_by(node, output):
    output.print_node(node.node)
    sbd = enums.SortByDir
    if node.sortby_dir == sbd.SORTBY_ASC:
        output.swrite('ASC')
    elif node.sortby_dir == sbd.SORTBY_DESC:
        output.swrite('DESC')
    elif node.sortby_dir == sbd.SORTBY_USING:
        output.swrites('USING')
        output.write(node.useOp.string_value)
    sbn = enums.SortByNulls
    if node.sortby_nulls != sbn.SORTBY_NULLS_DEFAULT:
        output.swrites('NULLS')
        output.write('FIRST' if node.sortby_nulls == sbn.SORTBY_NULLS_FIRST else 'LAST')
github lelit / pglast / pglast / printers / dml.py View on Github external
def _select_needs_to_be_wrapped_in_parens(node):
    # Accordingly with https://www.postgresql.org/docs/current/sql-select.html, a SELECT
    # statement on either sides of UNION/INTERSECT/EXCEPT must be wrapped in parens if it
    # contains ORDER BY/LIMIT/... or is a nested UNION/INTERSECT/EXCEPT
    return (node.sortClause
            or node.limitCount
            or node.limitOffset
            or node.lockingClause
            or node.op != enums.SetOperation.SETOP_NONE)
github lelit / pglast / pglast / printers / ddl.py View on Github external
else:
        output.write(node.priv_name.value.upper())
    if node.cols is not Missing:
        output.write(' (')
        output.print_list(node.cols, ',', are_names=True)
        output.write(')')


OBJECT_NAMES = {
    enums.ObjectType.OBJECT_ACCESS_METHOD: 'ACCESS METHOD',
    enums.ObjectType.OBJECT_AGGREGATE: 'AGGREGATE',
    enums.ObjectType.OBJECT_AMOP: 'AMOP',
    enums.ObjectType.OBJECT_AMPROC: 'AMPROC',
    enums.ObjectType.OBJECT_ATTRIBUTE: 'ATTRIBUTE',
    enums.ObjectType.OBJECT_CAST: 'CAST',
    enums.ObjectType.OBJECT_COLUMN: 'COLUMN',
    enums.ObjectType.OBJECT_COLLATION: 'COLLATION',
    enums.ObjectType.OBJECT_CONVERSION: 'CONVERSION',
    enums.ObjectType.OBJECT_DATABASE: 'DATABASE',
    enums.ObjectType.OBJECT_DEFAULT: 'DEFAULT',
    enums.ObjectType.OBJECT_DEFACL: 'DEFACL',
    enums.ObjectType.OBJECT_DOMAIN: 'DOMAIN',
    enums.ObjectType.OBJECT_DOMCONSTRAINT: 'CONSTRAINT',
    enums.ObjectType.OBJECT_EVENT_TRIGGER: 'EVENT TRIGGER',
    enums.ObjectType.OBJECT_EXTENSION: 'EXTENSION',
    enums.ObjectType.OBJECT_FDW: 'FOREIGN DATA WRAPPER',
    enums.ObjectType.OBJECT_FOREIGN_SERVER: 'SERVER',
    enums.ObjectType.OBJECT_FOREIGN_TABLE: 'FOREIGN TABLE',
    enums.ObjectType.OBJECT_FUNCTION: 'FUNCTION',
    enums.ObjectType.OBJECT_INDEX: 'INDEX',
    enums.ObjectType.OBJECT_LANGUAGE: 'LANGUAGE',
    enums.ObjectType.OBJECT_LARGEOBJECT: 'LARGE OBJECT',