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

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

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 311x 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} from "../combi";
import {SQLSource, SQLFieldName, Dynamic, Select, SQLIn, SQLCompareOperator, SQLFunction} from ".";
import {Version} from "../../../version";
import {IStatementRunnable} from "../statement_runnable";
 
export class SQLCompare extends Expression {
  public getRunnable(): IStatementRunnable {
    const subSelect = 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")), subSelect);
 
    const arith = ver(Version.v750, plusPrio(seq(altPrio("+", "-", "*", "/"), SQLFieldName)));
 
    const rett = seq(altPrio(SQLFunction, seq(SQLFieldName, optPrio(arith))),
                     altPrio(seq(SQLCompareOperator, altPrio(sub, source)),
                             seq(optPrio("NOT"), altPrio(SQLIn, like, between)),
                             nul));
 
    const exists = seq("EXISTS", subSelect);
 
    return altPrio(exists, Dynamic, rett);
  }
}