All files / src/abap/2_statements/expressions select_loop.ts

100% Statements 57/57
100% Branches 1/1
100% Functions 1/1
100% Lines 57/57

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 571x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x
import {seq, per, alt, Expression, optPrio, altPrio, ver, plusPrio} from "../combi";
import {SQLSource, SQLFrom, SQLCond, SQLIntoTable, SQLGroupBy, SQLClient, SQLForAllEntries, SQLIntoList, SQLAggregation, DatabaseConnection} from ".";
import {IStatementRunnable} from "../statement_runnable";
import {SQLOrderBy} from "./sql_order_by";
import {SQLHaving} from "./sql_having";
import {SQLIntoStructure} from "./sql_into_structure";
import {SQLHints} from "./sql_hints";
import {SQLFieldListLoop} from "./sql_field_list_loop";
import {SQLUpTo} from "./sql_up_to";
import {Version} from "../../../version";
import {SQLFieldsLoop} from "./sql_fields_loop";
 
// note: SELECT loops are matched before single statement SELECTs
export class SelectLoop extends Expression {
  public getRunnable(): IStatementRunnable {
    const where = seq("WHERE", SQLCond);
 
    const bypass = "BYPASSING BUFFER";
 
    const pack = seq("PACKAGE SIZE", SQLSource);
 
    const tab = seq(SQLIntoTable, alt(pack, seq(SQLFrom, pack), seq(pack, SQLFrom)));
 
    const packTab = seq(pack, SQLIntoTable);
 
    const into = altPrio(SQLIntoStructure, SQLIntoList);
 
    const perm = per(SQLFrom,
                     where,
                     SQLUpTo,
                     SQLOrderBy,
                     SQLHaving,
                     SQLClient,
                     bypass,
                     SQLGroupBy,
                     SQLForAllEntries,
                     DatabaseConnection,
                     alt(tab, SQLIntoStructure, SQLIntoList, packTab));
 
    const strict = seq(SQLFrom,
                       ver(Version.v750, SQLFieldsLoop),
                       optPrio(SQLForAllEntries),
                       optPrio(seq(where, optPrio(SQLOrderBy), into, optPrio(SQLUpTo))));
 
    const aggrIntoBeforeFrom = seq(plusPrio(SQLAggregation), into,
                                   optPrio(SQLUpTo), SQLFrom, optPrio(SQLClient), optPrio(where), SQLGroupBy);
 
    const aggrIntoAfterFrom = seq(plusPrio(SQLAggregation), SQLFrom,
                                  optPrio(SQLClient), into, optPrio(SQLUpTo), optPrio(where), SQLGroupBy);
 
    const ret = seq("SELECT",
                    altPrio(seq(optPrio("DISTINCT"), SQLFieldListLoop, perm), strict, aggrIntoBeforeFrom, aggrIntoAfterFrom),
                    optPrio(SQLHints));
 
    return ret;
  }
}