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

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

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 551x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 299x 1x
import {seq, per, opt, alt, ver, star, Expression, optPrio, altPrio} from "../combi";
import {SQLSource, SQLFrom, Dynamic, SQLCond, SQLFieldName, SQLAggregation, SQLIntoTable, SQLGroupBy, SQLForAllEntries} from ".";
import {Version} from "../../../version";
import {IStatementRunnable} from "../statement_runnable";
import {SQLOrderBy} from "./sql_order_by";
import {SQLHaving} from "./sql_having";
import {SQLPath} from "./sql_path";
import {SQLAsName} from "./sql_as_name";
import {SQLCase} from "./sql_case";
import {SQLIntoStructure} from "./sql_into_structure";
import {SQLFieldList} from "./sql_field_list";
import {SQLHints} from "./sql_hints";
import {SQLFunction} from "./sql_function";
 
export class SelectLoop extends Expression {
  public getRunnable(): IStatementRunnable {
    const where = seq("WHERE", SQLCond);
 
    const comma = opt(ver(Version.v740sp05, ","));
    const as = seq("AS", SQLAsName);
    const someField = seq(alt(SQLFieldName, SQLPath, SQLAggregation, SQLFunction, SQLCase), optPrio(as), comma);
    const fieldList = seq(star(someField), alt(SQLFieldName, SQLPath), optPrio(as), comma, star(someField));
 
// todo, use SQLFieldList instead?
    const fields = alt("*", Dynamic, fieldList);
 
    const client = "CLIENT SPECIFIED";
    const bypass = "BYPASSING BUFFER";
 
    const up = seq("UP TO", SQLSource, "ROWS");
 
    const pack = seq("PACKAGE SIZE", SQLSource);
 
    const tab = seq(SQLIntoTable, alt(pack, seq(SQLFrom, pack), seq(pack, SQLFrom)));
 
    const perm = per(SQLFrom,
                     where,
                     up,
                     SQLOrderBy,
                     SQLHaving,
                     client,
                     bypass,
                     SQLGroupBy,
                     SQLForAllEntries,
                     alt(tab, SQLIntoStructure));
 
    const strict = seq(SQLFrom, "FIELDS", SQLFieldList, where, SQLIntoStructure, up);
 
    const ret = seq("SELECT",
                    altPrio(seq(optPrio("DISTINCT"), fields, perm), strict),
                    optPrio(SQLHints));
 
    return ret;
  }
}