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

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

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 441x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x
import {ver, seq, tok, starPrio, alt, optPrio, altPrio, Expression, plusPrio} from "../combi";
import {SQLSource, SQLFieldName, Dynamic, Select, SQLCompareOperator} from ".";
import {WParenLeft, WParenLeftW, ParenLeftW, WParenRightW} from "../../1_lexer/tokens";
import {Version} from "../../../version";
import {IStatementRunnable} from "../statement_runnable";
 
export class SQLCompare extends Expression {
  public getRunnable(): IStatementRunnable {
    const val = new SQLSource();
 
    const list = seq(altPrio(tok(WParenLeft), tok(WParenLeftW)), val, starPrio(seq(",", val)), ")");
 
    const subSelect = seq("(", Select, ")");
 
    const inn = seq(optPrio("NOT"),
                    "IN",
                    altPrio(SQLSource, list, subSelect));
 
    const between = seq(optPrio("NOT"), "BETWEEN", SQLSource, "AND", SQLSource);
 
    const like = seq(optPrio("NOT"), "LIKE", SQLSource, optPrio(seq("ESCAPE", SQLSource)));
 
    const nul = seq("IS", optPrio("NOT"), alt("NULL", ver(Version.v753, "INITIAL")));
 
    const source = new SQLSource();
 
    const sub = seq(optPrio(altPrio("ALL", "ANY", "SOME")), subSelect);
 
    const builtin = ver(Version.v751, seq(alt("lower", "upper"), tok(ParenLeftW), SQLFieldName, tok(WParenRightW)));
 
    const arith = ver(Version.v750, seq(SQLFieldName, plusPrio(seq(altPrio("+", "-", "*", "/"), SQLFieldName))));
 
    const rett = seq(altPrio(builtin, arith, SQLFieldName),
                     altPrio(seq(SQLCompareOperator, altPrio(sub, source)),
                             inn,
                             like,
                             between,
                             nul));
 
    const exists = seq("EXISTS", subSelect);
 
    return altPrio(exists, Dynamic, rett);
  }
}