How to use the pglast.printer.node_printer 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 / tests / test_printer.py View on Github external
        @printer.node_printer('test_tag1')
        def tag1(node, output):
            pass
github lelit / pglast / pglast / printers / dml.py View on Github external
@node_printer('SQLValueFunction')
def sql_value_function(node, output):
    svfo = enums.SQLValueFunctionOp
    if node.op == svfo.SVFOP_CURRENT_DATE:
        output.write('CURRENT_DATE')
    elif node.op == svfo.SVFOP_CURRENT_TIME:
        output.write('CURRENT_TIME')
    elif node.op == svfo.SVFOP_CURRENT_TIME_N:  # pragma: no cover
        # FIXME: understand the meaning of this
        raise NotImplementedError('CURRENT_TIME_N')
    elif node.op == svfo.SVFOP_CURRENT_TIMESTAMP:
        output.write('CURRENT_TIMESTAMP')
    elif node.op == svfo.SVFOP_CURRENT_TIMESTAMP_N:  # pragma: no cover
        # FIXME: understand the meaning of this
        raise NotImplementedError('CURRENT_TIMESTAMP_N')
    elif node.op == svfo.SVFOP_LOCALTIME:
        output.write('LOCALTIME')
github lelit / pglast / pglast / printers / ddl.py View on Github external
@node_printer('DropdbStmt')
def drop_db_stmt(node, output):
    output.write('DROP DATABASE')
    if node.missing_ok:
        output.write(' IF EXISTS')
    output.write(' ')
    output.print_name(node.dbname)
github lelit / pglast / pglast / printers / ddl.py View on Github external
@node_printer('DiscardStmt')
def discard_stmt(node, output):
    output.write('DISCARD ')
    if node.target == enums.DiscardMode.DISCARD_ALL:
        output.write('ALL')
    elif node.target == enums.DiscardMode.DISCARD_PLANS:
        output.write('PLANS')
    elif node.target == enums.DiscardMode.DISCARD_SEQUENCES:
        output.write('SEQUENCES')
    elif node.target == enums.DiscardMode.DISCARD_TEMP:
        output.write('TEMP')
    else:
        raise NotImplementedError('Invalid target for discard: %s' %
                                  node.target)
github lelit / pglast / pglast / printers / dml.py View on Github external
@node_printer('InferClause')
def infer_clause(node, output):
    if node.conname:
        output.swrite('ON CONSTRAINT ')
        output.print_name(node.conname)
    if node.indexElems:
        output.swrite('(')
        output.print_list(node.indexElems)
        output.write(')')
    if node.whereClause:
        output.swrite('WHERE ')
        output.print_node(node.whereClause)
github lelit / pglast / pglast / printers / ddl.py View on Github external
@node_printer('VacuumStmt')
def vacuum_stmt(node, output):
    optint = node.options.value
    options = []
    if optint & enums.VacuumOption.VACOPT_VACUUM:
        options.append('VACUUM')
    if optint & enums.VacuumOption.VACOPT_FULL:
        options.append('FULL')
    if optint & enums.VacuumOption.VACOPT_FREEZE:
        options.append('FREEZE')
    if optint & enums.VacuumOption.VACOPT_VERBOSE:
        options.append('VERBOSE')
    if optint & enums.VacuumOption.VACOPT_ANALYZE:
        options.append('ANALYZE')
    if optint & enums.VacuumOption.VACOPT_DISABLE_PAGE_SKIPPING:
        options.append('DISABLE_PAGE_SKIPPING')
    if 'VACUUM' in options:
github lelit / pglast / pglast / printers / ddl.py View on Github external
@node_printer('DropTableSpaceStmt')
def drop_table_space_stmt(node, output):
    output.write('DROP TABLESPACE')
    if node.missing_ok:
        output.write(' IF EXISTS')
    output.write(' ')
    output.print_name(node.tablespacename)
github lelit / pglast / pglast / printers / ddl.py View on Github external
@node_printer('LockStmt')
def lock_stmt(node, output):
    output.write('LOCK ')
    output.print_list(node.relations, ',')
    lock_mode = node.mode.value
    lock_str = LOCK_MODE_NAMES[lock_mode]
    output.write('IN ')
    output.write(lock_str)
    output.write(' MODE')
    if node.nowait:
        output.write(' NOWAIT')
github lelit / pglast / pglast / printers / dml.py View on Github external
@node_printer('DeleteStmt')
def delete_stmt(node, output):
    with output.push_indent():
        if node.withClause:
            output.write('WITH ')
            output.print_node(node.withClause)
            output.newline()
            output.space(2)
            output.indent()

        output.write('DELETE FROM ')
        output.print_node(node.relation)
        if node.usingClause:
            output.newline()
            output.write('USING ')
            output.print_list(node.usingClause)
        if node.whereClause:
github lelit / pglast / pglast / printers / ddl.py View on Github external
@node_printer('CreateEnumStmt')
def create_enum_stmt(node, output):
    output.write('CREATE TYPE ')
    output.print_name(node.typeName)
    output.write('AS ENUM (')
    output.print_list(node.vals)
    output.write(')')