UNPKG

sedk-mysql

Version:
213 lines 9.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NumberColumn = void 0; const AggregateFunction_1 = require("../AggregateFunction"); const binder_1 = require("../binder"); const Column_1 = require("./Column"); const models_1 = require("../models"); const operators_1 = require("../operators"); const singletoneConstants_1 = require("../singletoneConstants"); const UpdateSetItemInfo_1 = require("../UpdateSetItemInfo"); class NumberColumn extends Column_1.Column { constructor(data) { super(data); } isEq(value) { const qualifier = value === null ? operators_1.NullOperator.Is : operators_1.ComparisonOperator.Equal; return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: qualifier, rightExpression: models_1.Expression.getSimpleExp(value), }); } eq(value1, op, value2) { if (value1 === null || value1 instanceof singletoneConstants_1.Default) { return new UpdateSetItemInfo_1.UpdateSetItemInfo(this, value1); } else if (op !== undefined && value2 !== undefined) { return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.Equal, rightExpression: models_1.Expression.getComplexExp(value1, op, value2), }); } else { return new models_1.UpdateCondition(this, models_1.Expression.getSimpleExp(value1)); } } isEq$(value) { const qualifier = value === null ? operators_1.NullOperator.Is : operators_1.ComparisonOperator.Equal; const binder = new binder_1.Binder(value); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: qualifier, rightExpression: models_1.Expression.getSimpleExp(binder), }); } eq$(value) { const binder = new binder_1.Binder(value); if (value === null) { return new UpdateSetItemInfo_1.UpdateSetItemInfo(this, models_1.Expression.getSimpleExp(binder)); } return new models_1.UpdateCondition(this, models_1.Expression.getSimpleExp(binder)); } isNe(value) { const qualifier = value === null ? operators_1.NullOperator.IsNot : operators_1.ComparisonOperator.NotEqual; return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: qualifier, rightExpression: models_1.Expression.getSimpleExp(value), }); } ne(value1, op, value2) { const rightExpression = (op !== undefined && value2 !== undefined) ? models_1.Expression.getComplexExp(value1, op, value2) : models_1.Expression.getSimpleExp(value1); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.NotEqual, rightExpression: rightExpression, }); } isNe$(value) { const qualifier = value === null ? operators_1.NullOperator.IsNot : operators_1.ComparisonOperator.NotEqual; const binder = new binder_1.Binder(value); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: qualifier, rightExpression: models_1.Expression.getSimpleExp(binder), }); } gt(value) { return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.GreaterThan, rightExpression: models_1.Expression.getSimpleExp(value), }); } gt$(value) { const binder = new binder_1.Binder(value); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.GreaterThan, rightExpression: models_1.Expression.getSimpleExp(binder), }); } ge(value) { return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.GreaterOrEqual, rightExpression: models_1.Expression.getSimpleExp(value), }); } ge$(value) { const binder = new binder_1.Binder(value); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.GreaterOrEqual, rightExpression: models_1.Expression.getSimpleExp(binder), }); } lt(value) { return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.LesserThan, rightExpression: models_1.Expression.getSimpleExp(value), }); } lt$(value) { const binder = new binder_1.Binder(value); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.LesserThan, rightExpression: models_1.Expression.getSimpleExp(binder), }); } le(value) { return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.LesserOrEqual, rightExpression: models_1.Expression.getSimpleExp(value), }); } le$(value) { const binder = new binder_1.Binder(value); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.LesserOrEqual, rightExpression: models_1.Expression.getSimpleExp(binder), }); } in(...values) { Column_1.Column.throwIfArrayIsEmpty(values, operators_1.ComparisonOperator.In); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.In, rightExpression: models_1.Expression.getSimpleExp(values), }); } in$(...values) { Column_1.Column.throwIfArrayIsEmpty(values, operators_1.ComparisonOperator.In); const binderArray = new binder_1.BinderArray(values.map(it => new binder_1.Binder(it))); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.In, rightExpression: models_1.Expression.getSimpleExp(binderArray), }); } notIn(...values) { Column_1.Column.throwIfArrayIsEmpty(values, operators_1.ComparisonOperator.NotIn); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.NotIn, rightExpression: models_1.Expression.getSimpleExp(values), }); } notIn$(...values) { Column_1.Column.throwIfArrayIsEmpty(values, operators_1.ComparisonOperator.NotIn); const binderArray = new binder_1.BinderArray(values.map(it => new binder_1.Binder(it))); return new models_1.Condition({ leftExpression: models_1.Expression.getSimpleExp(this), operator: operators_1.ComparisonOperator.NotIn, rightExpression: models_1.Expression.getSimpleExp(binderArray), }); } bitwiseAnd(value) { return models_1.Expression.getComplexExp(this, operators_1.BitwiseOperator.BitwiseAnd, value); } bitwiseAnd$(value) { const binder = new binder_1.Binder(value); return models_1.Expression.getComplexExp(this, operators_1.BitwiseOperator.BitwiseAnd, models_1.Expression.getSimpleExp(binder)); } bitwiseOr(value) { return models_1.Expression.getComplexExp(this, operators_1.BitwiseOperator.BitwiseOr, value); } bitwiseOr$(value) { const binder = new binder_1.Binder(value); return models_1.Expression.getComplexExp(this, operators_1.BitwiseOperator.BitwiseOr, models_1.Expression.getSimpleExp(binder)); } bitwiseXor(value) { return models_1.Expression.getComplexExp(this, operators_1.BitwiseOperator.BitwiseXor, value); } bitwiseXor$(value) { const binder = new binder_1.Binder(value); return models_1.Expression.getComplexExp(this, operators_1.BitwiseOperator.BitwiseXor, models_1.Expression.getSimpleExp(binder)); } get sum() { return new AggregateFunction_1.AggregateFunction(AggregateFunction_1.AggregateFunctionEnum.SUM, models_1.Expression.getSimpleExp(this)); } get avg() { return new AggregateFunction_1.AggregateFunction(AggregateFunction_1.AggregateFunctionEnum.AVG, models_1.Expression.getSimpleExp(this)); } get count() { return new AggregateFunction_1.AggregateFunction(AggregateFunction_1.AggregateFunctionEnum.COUNT, models_1.Expression.getSimpleExp(this)); } get max() { return new AggregateFunction_1.AggregateFunction(AggregateFunction_1.AggregateFunctionEnum.MAX, models_1.Expression.getSimpleExp(this)); } get min() { return new AggregateFunction_1.AggregateFunction(AggregateFunction_1.AggregateFunctionEnum.MIN, models_1.Expression.getSimpleExp(this)); } } exports.NumberColumn = NumberColumn; //# sourceMappingURL=NumberColumn.js.map