UNPKG

ts-sql-query

Version:

Type-safe SQL query builder like QueryDSL or JOOQ in Java or Linq in .Net for TypeScript with MariaDB, MySql, Oracle, PostgreSql, Sqlite and SqlServer support.

879 lines 131 kB
"use strict"; var _a, _b, _c, _d, _e, _f; Object.defineProperty(exports, "__esModule", { value: true }); exports.NullAllowWhenAggregateValueAsArrayValueSource = exports.NullAggregateValueAsArrayValueSource = exports.AllowWhenAggregateValueAsArrayValueSource = exports.AggregateValueAsArrayValueSource = exports.NullAllowWhenAggregateSelectValueSource = exports.NullAggregateSelectValueSource = exports.AllowWhenAggregateSelectValueSource = exports.AggregateSelectValueSource = exports.InlineSelectValueSource = exports.AllowWhenTableOrViewRawFragmentValueSource = exports.TableOrViewRawFragmentValueSource = exports.AggregateFunctions1or2ValueSource = exports.AggregateFunctions1ValueSource = exports.NullValueSource = exports.AggregateFunctions0ValueSource = exports.AllowWhenValueSource = exports.ValueSourceFromBuilder = exports.FragmentValueSource = exports.SequenceValueSource = exports.NoopValueSource = exports.SqlOperation2ValueSourceIfValueOrIgnore = exports.SqlOperation2ValueSource = exports.SqlOperation1ValueSourceIfValueOrIgnore = exports.SqlOperationValueSourceIfValueAlwaysNoop = exports.SqlOperationInValueSourceIfValueOrNoop = exports.SqlOperation1ValueSourceIfValueOrNoop = exports.SqlOperation1NotOptionalValueSource = exports.SqlOperationValueWhenNullValueSource = exports.SqlOperationInValueSource = exports.SqlOperation1ValueSource = exports.SqlOperationIsNullValueSource = exports.SqlOperation0ValueSource = exports.SqlOperationConstValueSource = exports.SqlOperationStatic1ValueSource = exports.ValueWhenNoValueValueSource = exports.BooleanValueWhenNoValueValueSource = exports.SqlOperationStaticBooleanValueSource = exports.SqlOperationStatic0ValueSource = exports.ValueSourceImpl = void 0; const SqlBuilder_1 = require("../sqlBuilders/SqlBuilder"); const values_1 = require("../expressions/values"); const TypeAdapter_1 = require("../TypeAdapter"); const ITableOrView_1 = require("../utils/ITableOrView"); const symbols_1 = require("../utils/symbols"); const ITableOrView_2 = require("../utils/ITableOrView"); const values_2 = require("../expressions/values"); const ProxyTypeAdapter_1 = require("./ProxyTypeAdapter"); class ValueSourceImpl { constructor(valueType, valueTypeName, optionalType, typeAdapter, aggregatedArrayColumns, aggregatedArrayMode, uuidString) { this[_a] = true; this.__valueType = valueType; this.__valueTypeName = valueTypeName; this.__optionalType = optionalType; this.__typeAdapter = typeAdapter; if (aggregatedArrayColumns) { this.__aggregatedArrayColumns = aggregatedArrayColumns; this.__aggregatedArrayMode = aggregatedArrayMode; } if (uuidString) { this.__uuidString = uuidString; } } __toSqlForCondition(sqlBuilder, params) { return this.__toSql(sqlBuilder, params); } __addWiths(_sqlBuilder, _withs) { // Do nothing } __registerTableOrView(_sqlBuilder, _requiredTablesOrViews) { // Do nothing } __registerRequiredColumn(_sqlBuilder, _requiredColumns, _onlyForTablesOrViews) { // Do nothing } __getOldValues(_sqlBuilder) { return undefined; } __getValuesForInsert(_sqlBuilder) { return undefined; } __isAllowed(_sqlBuilder) { return true; } isConstValue() { return false; } getConstValue() { throw new Error('You are trying to access to the const value when the expression is not const'); } allowWhen(when, error) { let result; if (typeof error === 'string') { result = new AllowWhenValueSource(when, new Error(error), this); } else { result = new AllowWhenValueSource(when, error, this); } if (this.__uuidString) { result.__uuidString = this.__uuidString; } return result; } disallowWhen(when, error) { let result; if (typeof error === 'string') { result = new AllowWhenValueSource(!when, new Error(error), this); } else { result = new AllowWhenValueSource(!when, error, this); } if (this.__uuidString) { result.__uuidString = this.__uuidString; } return result; } asOptional() { const result = new NoopValueSource(this, this.__valueType, this.__valueTypeName, 'optional', this.__typeAdapter); if (this.__uuidString) { result.__uuidString = this.__uuidString; } return result; } asRequiredInOptionalObject() { const result = new NoopValueSource(this, this.__valueType, this.__valueTypeName, 'requiredInOptionalObject', this.__typeAdapter); if (this.__aggregatedArrayColumns) { result.__aggregatedArrayColumns = this.__aggregatedArrayColumns; result.__aggregatedArrayMode = this.__aggregatedArrayMode; } if (this.__uuidString) { result.__uuidString = this.__uuidString; } return result; } useEmptyArrayForNoValue() { const result = new NoopValueSource(this, this.__valueType, this.__valueTypeName, 'required', this.__typeAdapter); if (this.__aggregatedArrayColumns) { result.__aggregatedArrayColumns = this.__aggregatedArrayColumns; result.__aggregatedArrayMode = this.__aggregatedArrayMode; } if (this.__uuidString) { result.__uuidString = this.__uuidString; } return result; } asOptionalNonEmptyArray() { const result = new NoopValueSource(this, this.__valueType, this.__valueTypeName, 'optional', this.__typeAdapter); if (this.__aggregatedArrayColumns) { result.__aggregatedArrayColumns = this.__aggregatedArrayColumns; result.__aggregatedArrayMode = this.__aggregatedArrayMode; } if (this.__uuidString) { result.__uuidString = this.__uuidString; } return result; } projectingOptionalValuesAsNullable() { return this; } // SqlComparator0 isNull() { return condition(new SqlOperationIsNullValueSource('_isNull', this, 'boolean', 'boolean', 'required', this.__typeAdapter)); } isNotNull() { return condition(new SqlOperationIsNullValueSource('_isNotNull', this, 'boolean', 'boolean', 'required', this.__typeAdapter)); } // SqlComparator1 equalsIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_equals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } equals(value) { return condition(new SqlOperation1ValueSource('_equals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notEqualsIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_notEquals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notEquals(value) { return condition(new SqlOperation1ValueSource('_notEquals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } isIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_is', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } is(value) { return condition(new SqlOperation1NotOptionalValueSource('_is', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } isNotIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_isNot', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } isNot(value) { return condition(new SqlOperation1NotOptionalValueSource('_isNot', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } asString() { const result = new SqlOperation0ValueSource('_asString', this, 'string', 'string', this.__optionalType, this.__typeAdapter); result.__uuidString = this.__valueType === 'uuid' || this.__valueType === 'customUuid'; return result; } onlyWhenOrNull(when) { if (when) { return this; } else { return new NullValueSource(this.__valueType, this.__valueTypeName, 'optional', this.__typeAdapter); } } ignoreWhenAsNull(when) { if (when) { return new NullValueSource(this.__valueType, this.__valueTypeName, 'optional', this.__typeAdapter); } else { return this; } } equalsInsensitiveIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_equalsInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } equalsInsensitive(value) { return condition(new SqlOperation1ValueSource('_equalsInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notEqualsInsensitiveIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_notEqualsInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notEqualsInsensitive(value) { return condition(new SqlOperation1ValueSource('_notEqualsInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } /** @deprecated use lessThanIfValue method instead */ smallerIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_lessThan', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } /** @deprecated use lessThan method instead */ smaller(value) { return condition(new SqlOperation1ValueSource('_lessThan', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } /** @deprecated use greaterThanIfValue method instead */ largerIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_greaterThan', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } /** @deprecated use greaterThan method instead */ larger(value) { return condition(new SqlOperation1ValueSource('_greaterThan', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } /** @deprecated use lessOrEqualsIfValue method instead */ smallAsIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_lessOrEquals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } /** @deprecated use lessOrEquals method instead */ smallAs(value) { return condition(new SqlOperation1ValueSource('_lessOrEquals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } /** @deprecated use greaterOrEqualsIfValue method instead */ largeAsIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_greaterOrEquals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } /** @deprecated use greaterOrEquals method instead */ largeAs(value) { return condition(new SqlOperation1ValueSource('_greaterOrEquals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } lessThanIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_lessThan', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } lessThan(value) { return condition(new SqlOperation1ValueSource('_lessThan', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } greaterThanIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_greaterThan', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } greaterThan(value) { return condition(new SqlOperation1ValueSource('_greaterThan', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } lessOrEqualsIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_lessOrEquals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } lessOrEquals(value) { return condition(new SqlOperation1ValueSource('_lessOrEquals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } greaterOrEqualsIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_greaterOrEquals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } greaterOrEquals(value) { return condition(new SqlOperation1ValueSource('_greaterOrEquals', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } inIfValue(value) { return condition(new SqlOperationInValueSourceIfValueOrNoop('_in', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } in(value) { return condition(new SqlOperationInValueSource('_in', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notInIfValue(value) { return condition(new SqlOperationInValueSourceIfValueOrNoop('_notIn', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notIn(value) { return condition(new SqlOperationInValueSource('_notIn', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } inN(...value) { return condition(new SqlOperationInValueSource('_in', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notInN(...value) { return condition(new SqlOperationInValueSource('_notIn', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } likeIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_like', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } like(value) { return condition(new SqlOperation1ValueSource('_like', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notLikeIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_notLike', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notLike(value) { return condition(new SqlOperation1ValueSource('_notLike', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } likeInsensitiveIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_likeInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } likeInsensitive(value) { return condition(new SqlOperation1ValueSource('_likeInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notLikeInsensitiveIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_notLikeInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notLikeInsensitive(value) { return condition(new SqlOperation1ValueSource('_notLikeInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } startsWithIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_startsWith', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } startsWith(value) { return condition(new SqlOperation1ValueSource('_startsWith', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notStartsWithIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_notStartsWith', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notStartsWith(value) { return condition(new SqlOperation1ValueSource('_notStartsWith', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } endsWithIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_endsWith', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } endsWith(value) { return condition(new SqlOperation1ValueSource('_endsWith', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notEndsWithIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_notEndsWith', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notEndsWith(value) { return condition(new SqlOperation1ValueSource('_notEndsWith', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } startsWithInsensitiveIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_startsWithInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } startsWithInsensitive(value) { return condition(new SqlOperation1ValueSource('_startsWithInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notStartsWithInsensitiveIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_notStartsWithInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notStartsWithInsensitive(value) { return condition(new SqlOperation1ValueSource('_notStartsWithInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } endsWithInsensitiveIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_endsWithInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } endsWithInsensitive(value) { return condition(new SqlOperation1ValueSource('_endsWithInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notEndsWithInsensitiveIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_notEndsWithInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notEndsWithInsensitive(value) { return condition(new SqlOperation1ValueSource('_notEndsWithInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } containsIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_contains', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } contains(value) { return condition(new SqlOperation1ValueSource('_contains', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notContainsIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_notContains', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notContains(value) { return condition(new SqlOperation1ValueSource('_notContains', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } containsInsensitiveIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_containsInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } containsInsensitive(value) { return condition(new SqlOperation1ValueSource('_containsInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notContainsInsensitiveIfValue(value) { return condition(new SqlOperation1ValueSourceIfValueOrNoop('_notContainsInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notContainsInsensitive(value) { return condition(new SqlOperation1ValueSource('_notContainsInsensitive', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } // SqlComparator2 between(value, value2) { return condition(new SqlOperation2ValueSource('_between', this, value, value2, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } notBetween(value, value2) { return condition(new SqlOperation2ValueSource('_notBetween', this, value, value2, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } // SqlFunctionStatic: never used here // SqlFunction0 // Boolean negate() { return condition(new SqlOperation0ValueSource('_negate', this, 'boolean', 'boolean', this.__optionalType, this.__typeAdapter)); } onlyWhen(condition) { if (condition) { return this; } else { return new SqlOperationValueSourceIfValueAlwaysNoop(); } } ignoreWhen(condition) { if (condition) { return new SqlOperationValueSourceIfValueAlwaysNoop(); } else { return this; } } trueWhenNoValue() { const result = new BooleanValueWhenNoValueValueSource('_true', this, 'boolean', 'boolean', this.__optionalType, this.__typeAdapter); result.__isBooleanForCondition = this.__isBooleanForCondition; return result; } falseWhenNoValue() { const result = new BooleanValueWhenNoValueValueSource('_false', this, 'boolean', 'boolean', this.__optionalType, this.__typeAdapter); result.__isBooleanForCondition = this.__isBooleanForCondition; return result; } valueWhenNoValue(value) { if (value === true) { return this.trueWhenNoValue(); } if (value === false) { return this.falseWhenNoValue(); } const result = new ValueWhenNoValueValueSource(value, this, 'boolean', 'boolean', this.__optionalType, this.__typeAdapter); result.__isBooleanForCondition = this.__isBooleanForCondition; return result; } // String toLowerCase() { return new SqlOperation0ValueSource('_toLowerCase', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } /** @deprecated use toLowerCase method instead */ lower() { return new SqlOperation0ValueSource('_toLowerCase', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } toUpperCase() { return new SqlOperation0ValueSource('_toUpperCase', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } /** @deprecated use toUpperCase method instead */ upper() { return new SqlOperation0ValueSource('_toUpperCase', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } length() { return new SqlOperation0ValueSource('_length', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } trim() { return new SqlOperation0ValueSource('_trim', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } trimLeft() { return new SqlOperation0ValueSource('_trimLeft', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } /** @deprecated use trimLeft method instead */ ltrim() { return new SqlOperation0ValueSource('_trimLeft', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } trimRight() { return new SqlOperation0ValueSource('_trimRight', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } /** @deprecated use trimRight method instead */ rtrim() { return new SqlOperation0ValueSource('_trimRight', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } reverse() { return new SqlOperation0ValueSource('_reverse', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } // Number functions asDouble() { return new SqlOperation0ValueSource('_asDouble', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } /** @deprecated 'stringDouble' type is deprecated, define your customInt instead */ asStringDouble() { return new SqlOperation0ValueSource('_asDouble', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } asInt() { if (this.__valueType === 'double') { // Unsafe cast, it happens when TypeSafe is not in use, we round the value return new SqlOperation0ValueSource('_round', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { // Unsafe cast, it happens when TypeSafe is not in use, we round the value return new SqlOperation0ValueSource('_round', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } return new NoopValueSource(this, 'int', 'int', this.__optionalType, this.__typeAdapter); } /** @deprecated 'stringInt' type is deprecated, define your customInt instead */ asStringInt() { if (this.__valueType === 'double') { // Unsafe cast, it happens when TypeSafe is not in use, we round the value return new SqlOperation0ValueSource('_round', this, 'stringInt', 'stringInt', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { // Unsafe cast, it happens when TypeSafe is not in use, we round the value return new SqlOperation0ValueSource('_round', this, 'stringInt', 'stringInt', this.__optionalType, this.__typeAdapter); } return new NoopValueSource(this, 'stringInt', 'stringInt', this.__optionalType, this.__typeAdapter); } asBigint() { if (this.__valueType === 'double') { // Unsafe cast, it happens when TypeSafe is not in use, we round the value return new SqlOperation0ValueSource('_round', this, 'bigint', 'bigint', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { // Unsafe cast, it happens when TypeSafe is not in use, we round the value return new SqlOperation0ValueSource('_round', this, 'bigint', 'bigint', this.__optionalType, this.__typeAdapter); } return new NoopValueSource(this, 'bigint', 'bigint', this.__optionalType, this.__typeAdapter); } abs() { return new SqlOperation0ValueSource('_abs', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } ceil() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_ceil', this, 'stringInt', 'stringInt', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_ceil', this, 'stringInt', 'stringInt', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'bigint') { return new SqlOperation0ValueSource('_ceil', this, 'bigint', 'bigint', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customInt' || this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_ceil', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_ceil', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } } floor() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_floor', this, 'stringInt', 'stringInt', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_floor', this, 'stringInt', 'stringInt', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'bigint') { return new SqlOperation0ValueSource('_floor', this, 'bigint', 'bigint', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customInt' || this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_floor', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_floor', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } } round() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_round', this, 'stringInt', 'stringInt', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_round', this, 'stringInt', 'stringInt', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'bigint') { return new SqlOperation0ValueSource('_round', this, 'bigint', 'bigint', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customInt' || this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_round', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_round', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } } exp() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_exp', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_exp', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_exp', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } ln() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_ln', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_ln', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_ln', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_ln', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } log10() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_log10', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_log10', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_log10', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_log10', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } sqrt() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_sqrt', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_sqrt', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_sqrt', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_sqrt', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } cbrt() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_cbrt', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_cbrt', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_cbrt', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_cbrt', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } sign() { return new SqlOperation0ValueSource('_sign', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } // Trigonometric Functions acos() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_acos', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_acos', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_acos', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_acos', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } asin() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_asin', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_asin', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_asin', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_asin', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } atan() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_atan', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_atan', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_atan', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_atan', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } cos() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_cos', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_cos', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_cos', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_cos', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } cot() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_cot', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_cot', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_cot', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_cot', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } sin() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_sin', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_sin', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_sin', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_sin', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } tan() { if (this.__valueType === 'stringInt') { return new SqlOperation0ValueSource('_tan', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'stringDouble') { return new SqlOperation0ValueSource('_tan', this, 'stringDouble', 'stringDouble', this.__optionalType, this.__typeAdapter); } else if (this.__valueType === 'customDouble') { return new SqlOperation0ValueSource('_tan', this, this.__valueType, this.__valueTypeName, this.__optionalType, this.__typeAdapter); } else { return new SqlOperation0ValueSource('_tan', this, 'double', 'double', this.__optionalType, this.__typeAdapter); } } // Date & Time Functions getDate() { return new SqlOperation0ValueSource('_getDate', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } getTime() { return new SqlOperation0ValueSource('_getTime', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } getFullYear() { return new SqlOperation0ValueSource('_getFullYear', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } getMonth() { return new SqlOperation0ValueSource('_getMonth', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } getDay() { return new SqlOperation0ValueSource('_getDay', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } getHours() { return new SqlOperation0ValueSource('_getHours', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } getMinutes() { return new SqlOperation0ValueSource('_getMinutes', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } getSeconds() { return new SqlOperation0ValueSource('_getSeconds', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } getMilliseconds() { return new SqlOperation0ValueSource('_getMilliseconds', this, 'int', 'int', this.__optionalType, this.__typeAdapter); } // SqlFunction1 valueWhenNull(value) { return new SqlOperationValueWhenNullValueSource(this, value, this.__valueType, this.__valueTypeName, getOptionalType2(this, value), getTypeAdapter2(this, value)); } nullIfValue(value) { return new SqlOperation1ValueSource('_nullIfValue', this, value, this.__valueType, this.__valueTypeName, 'optional', getTypeAdapter2(this, value)); } and(value) { return condition(new SqlOperation1ValueSource('_and', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } or(value) { return condition(new SqlOperation1ValueSource('_or', this, value, 'boolean', 'boolean', getOptionalType2(this, value), getTypeAdapter2(this, value))); } // Trigonometric Functions atan2(value) { if (this.__valueType === 'stringInt') { return new SqlOperation1ValueSource('_atan2', this, value, 'stringDouble', 'stringDouble', getOptionalType2(this, value), getTypeAdapter2(this, value)); } else if (this.__valueType === 'stringDouble') { return new SqlOperation1ValueSource('_atan2', this, value, 'stringDouble', 'stringDouble', getOptionalType2(this, value), getTypeAdapter2(this, value)); } else if (this.__valueType === 'customDouble') { return new SqlOperation1ValueSource('_atan2', this, value, this.__valueType, this.__valueTypeName, getOptionalType2(this, value), getTypeAdapter2(this, value)); } else { return new SqlOperation1ValueSource('_atan2', this, value, 'double', 'double', getOptionalType2(this, value), getTypeAdapter2(this, value)); } } // String Functions concat(value) { return new SqlOperation1ValueSource('_concat', this, value, this.__valueType, this.__valueTypeName, getOptionalType2(this, value), getTypeAdapter2(this, value)); } concatIfValue(value) { return new SqlOperation1ValueSourceIfValueOrIgnore('_concat', this, value, this.__valueType, this.__valueTypeName, getOptionalType2(this, value), getTypeAdapter2(this, value)); } substrToEnd(start) { return new SqlOperation1ValueSource('_substrToEnd', this, start, this.__valueType, this.__valueTypeName, getOptionalType2(this, start), getTypeAdapter2(this, start)); } substringToEnd(start) { return new SqlOperation1ValueSource('_substringToEnd', this, start, this.__valueType, this.__valueTypeName, getOptionalType2(this, start), getTypeAdapter2(this, start)); } // Number power(value) { if (this.__valueType === 'stringInt') { return new SqlOperation1ValueSource('_power', this, value, 'stringDouble', 'stringDouble', getOptionalType2(this, value), getTypeAdapter2(this, value)); } else if (this.__valueType === 'stringDouble') { return new SqlOperation1ValueSource('_power', this, value, 'stringDouble', 'stringDouble', getOptionalType2(this, value), getTypeAdapter2(this, value)); } else if (this.__valueType === 'customDouble') { return new SqlOperation1ValueSource('_power', this, value, this.__valueType, this.__valueTypeName, getOptionalType2(this, value), getTypeAdapter2(this, value)); } else { return new SqlOperation1ValueSource('_power', this, value, 'double', 'double', getOptionalType2(this, value), getTypeAdapter2(this, value)); } } logn(value) { if (this.__valueType === 'stringInt') { return new SqlOperation1ValueSource('_logn', this, value, 'stringDouble', 'stringDouble', getOptionalType2(this, value), getTypeAdapter2(this, value)); } else if (this.__valueType === 'stringDouble') { return new SqlOperation1ValueSource('_logn', this, value, 'stringDouble', 'stringDouble', getOptionalType2(this, value), getTypeAdapter2(this, value)); } else if (this.__valueType === 'customDouble') { return new SqlOperation1ValueSource('_logn', this, value, this.__valueType, this.__valueTypeName, getOptionalType2(this, value), getTypeAdapter2(this, value)); } else { return new SqlOperation1ValueSource('_logn', this, value, 'double', 'double', getOptionalType2(this, value), getTypeAdapter2(this, value)); } } roundn(value) { if (this.__valueType === 'stringInt') { return new SqlOperation1ValueSource('_roundn', this, value, 'stringDouble', 'stringDouble', getOptionalType2(this, value), getTypeAdapter2(this, value)); } else if (this.__valueType === 'stringDouble') { return new SqlOperation1ValueSource('_roundn', this, value, 'stringDouble', 'stringDouble', getOptionalType2(this, value), getTypeAdapter2(this, value)); } else if (this.__valueType === 'customDouble') { return new SqlOperation1ValueSource('_roundn', this, value, this.__valueType, this.__valueTypeName, getOptionalType2(this, value), getTypeAdapter2(this, value)); } else { return new SqlOperation1ValueSource('_roundn', this, value, 'double', 'double', getOptionalType2(this, value), getTypeAdapter2(this, value)); } } /** * This function establish a minimum value for the current value, that means the biggest value must be returned */ minValue(value) { return createSqlOperation1ofOverloadedNumber(this, value, '_maximumBetweenTwoValues'); } /** * This function establish a maximun value for the current value, that means the smallest value must be returned */ maxValue(value) { return createSqlOperation1ofOverloadedNumber(this, value, '_minimumBetweenTwoValues'); } // Number operators add(value) { return createSqlOperation1ofOverloadedNumber(this, value, '_add'); } substract(value) { return createSqlOperation1ofOverloadedNumber(this, value, '_substract'); } multiply(value) { return createSqlOperation1ofOverloadedNumber(this, value, '_multiply'); } divide(value) { if (this.__valueType === 'stringInt') { return new SqlOperation1ValueSource('_divide', this, value, 'stringDouble', 'stringDouble', getOptionalType2(this, value), getTypeAdapter2(this, value)); } else if (this.__valueType === 'stringDouble') { return new SqlOperation1ValueSource('_divide', this, value, 'stringDouble', 'stringDouble', getOptionalType2(this, value), getTypeAdapter2(this, value)); } else if (this.__valueType === 'customDouble') { return new SqlOperation1ValueSource('_divide', this, value, this.__valueType, this.__valueTypeName, getOptionalType2(this, value), getTypeAdapter2(this, value)); } else { return new SqlOperation1ValueSource('_divide', this, value, 'double', 'double', getOptionalType2(this, value), getTypeAdapter2(this, value)); } } modulo(value) { return createSqlOperation1ofOverloadedNumber(this, value, '_modulo'); } /** @deprecated use modulo method instead */ mod(value) { return createSqlOperation1ofOverloadedNumber(this, value, '_modulo'); } // SqlFunction2 substr(start, count) { return new SqlOperation2ValueSource('_substr', this, start, count, this.__valueType, this.__valueTypeName, getOptionalType3(this, start, count), getTypeAdapter3(this, start, count)); } substring(start, end) { return new SqlOperation2ValueSource('_substring', this, start, end, this.__valueType, this.__valueTypeName, getOptionalType3(this, start, end), getTypeAdapter3(this, start, end)); } /** @deprecated use replaceAllIfValue method instead */ replaceIfValue(findString, replaceWith) { return new SqlOperation2ValueSourceIfValueOrIgnore('_replaceAll', this, findString, replaceWith, this.__valueType, this.__valueTypeName, getOptionalType3(this, findString, replaceWith), getTypeAdapter3(this, findString, replaceWith)); } /** @deprecated use replaceAll method instead */ replace(findString, replaceWith) {