All files / src/cds/expressions cds_table_field.ts

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

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 201x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import {CDSAnnotation, CDSAssociation, CDSComposition, CDSName, CDSPrefixedName, CDSType} from ".";
import {Expression, str, seq, star, optPrio, alt, altPrio} from "../../abap/2_statements/combi";
import {IStatementRunnable} from "../../abap/2_statements/statement_runnable";
 
export class CDSTableField extends Expression {
  public getRunnable(): IStatementRunnable {
    const nullability = optPrio(alt("NOT NULL", "NULL"));
    const excludingNames = seq(CDSName, star(seq(",", CDSName)));
    const excluding = seq("EXCLUDING", "{", excludingNames, "}");
    const includeField = seq("INCLUDE", CDSPrefixedName,
                             optPrio(altPrio(
                               seq(str("SIGNATURE ONLY"), optPrio(excluding)),
                               seq(excluding, optPrio(str("SIGNATURE ONLY"))),
                             )));
    const field = seq(optPrio(str("KEY")), CDSName, ":", CDSType, nullability);
    const assocOrComp = seq(CDSName, ":", alt(CDSComposition, CDSAssociation));
    return seq(star(CDSAnnotation), altPrio(includeField, assocOrComp, field), ";");
  }
}