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

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

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 361x 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, optPrio, altPrio, Expression, plusPrio, tok} from "../combi";
import {SQLSource, SQLFieldName, Dynamic, Select, SQLIn, SQLCompareOperator, SQLFunction, Source, SimpleSource3, SQLPath, ConstantString} from ".";
import {Version} from "../../../version";
import {IStatementRunnable} from "../statement_runnable";
import {ParenLeftW, WAt, WParenRightW} from "../../1_lexer/tokens";
 
export class SQLCompare extends Expression {
  public getRunnable(): IStatementRunnable {
    const subSelect = seq("(", Select, ")");
    const subSelectDouble = seq("(", "(", Select, ")", ")");
 
    const between = seq("BETWEEN", SQLSource, "AND", SQLSource);
 
    const like = seq("LIKE", SQLSource, optPrio(seq("ESCAPE", SQLSource)));
 
    const nul = seq("IS", optPrio("NOT"), altPrio("NULL", ver(Version.v753, "INITIAL")));
 
    const source = new SQLSource();
 
    const sub = seq(optPrio(altPrio("ALL", "ANY", "SOME")), altPrio(subSelect, subSelectDouble));
 
    const arith = ver(Version.v750, plusPrio(seq(altPrio("+", "-", "*", "/"), SQLFieldName)));
 
    const paren = seq(tok(ParenLeftW), Source, tok(WParenRightW));
    const at = ver(Version.v740sp05, seq(tok(WAt), altPrio(SimpleSource3, paren)));
 
    const rett = seq(altPrio(SQLFunction, ConstantString, seq(altPrio(SQLPath, SQLFieldName), optPrio(arith)), at),
                     altPrio(seq(SQLCompareOperator, altPrio(sub, source)),
                             seq(optPrio("NOT"), altPrio(SQLIn, like, between)),
                             nul));
 
    const exists = seq("EXISTS", subSelect);
 
    return altPrio(exists, Dynamic, rett);
  }
}