MCPcopy Create free account
hub / github.com/DanWahlin/CustomerManagerStandard / createExpr

Function createExpr

CustomerManager/Scripts/breeze.debug.js:10408–10457  ·  view source on GitHub ↗
(source, exprContext)

Source from the content-addressed store, hash-verified

10406 var DELIM = String.fromCharCode(191);
10407
10408 function createExpr(source, exprContext) {
10409 var entityType = exprContext.entityType;
10410
10411 // the right hand side of an 'in' clause
10412 if (Array.isArray(source)) {
10413 if (!exprContext.isRHS) {
10414 throw new Error("Array expressions are only permitted on the right hand side of a BinaryPredicate");
10415 }
10416 return new LitExpr(source, exprContext.dataType);
10417 }
10418
10419 if (!__isString(source)) {
10420 if (source != null && __isObject(source) && (!__isDate(source))) {
10421 if (source.value === undefined) {
10422 throw new Error("Unable to resolve an expression for: " + source + " on entityType: " + entityType.name);
10423 }
10424 if (source.isProperty) {
10425 return new PropExpr(source.value);
10426 } else {
10427 // we want to insure that any LitExpr created this way is tagged with 'hasExplicitDataType: true'
10428 // because we want to insure that if we roundtrip thru toJSON that we don't
10429 // accidentally reinterpret this node as a PropExpr.
10430 // return new LitExpr(source.value, source.dataType || context.dataType, !!source.dataType);
10431 return new LitExpr(source.value, source.dataType || exprContext.dataType, true);
10432 }
10433 } else {
10434 return new LitExpr(source, exprContext.dataType);
10435 }
10436 }
10437
10438 // if entityType is unknown then assume that the rhs is a literal
10439 if (exprContext.isRHS && (entityType == null || entityType.isAnonymous)) {
10440 return new LitExpr(source, exprContext.dataType);
10441 }
10442
10443 var regex = /\([^()]*\)/;
10444 var m;
10445 var tokens = [];
10446 var i = 0;
10447 while (m = regex.exec(source)) {
10448 var token = m[0];
10449 tokens.push(token);
10450 var repl = DELIM + i++;
10451 source = source.replace(token, repl);
10452 }
10453
10454 var expr = parseExpr(source, tokens, exprContext);
10455 expr._validate(entityType, exprContext.usesNameOnServer);
10456 return expr;
10457 }
10458
10459 function parseExpr(source, tokens, exprContext) {
10460 var parts = source.split(DELIM);

Callers 1

breeze.debug.jsFile · 0.85

Calls 4

__isStringFunction · 0.85
__isObjectFunction · 0.85
__isDateFunction · 0.85
parseExprFunction · 0.85

Tested by

no test coverage detected