ts-sql-query
Advanced tools
Comparing version 1.61.0 to 1.62.0
@@ -409,2 +409,5 @@ "use strict"; | ||
} | ||
buildFragmentWithMaybeOptionalArgs(...args) { | ||
return new FragmentQueryBuilder_1.FragmentFunctionBuilderMaybeOptional(this, args); | ||
} | ||
rawFragment(sql, ...params) { | ||
@@ -411,0 +414,0 @@ return new RawFragmentImpl_1.RawFragmentImpl(sql, params); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.asAlwaysIfValueSource = exports.Argument = exports.__getValueSourcePrivate = exports.__getValueSourceOfObject = exports.isValueSource = exports.__isLocalDateTimeValueSource = exports.__isLocalTimeValueSource = exports.__isLocalDateValueSource = exports.__isStringValueSource = exports.__isUuidValueType = exports.__isUuidValueSource = exports.__isBooleanValueType = exports.__isBooleanValueSource = void 0; | ||
exports.asAlwaysIfValueSource = exports.Argument = exports.__getValueSourcePrivate = exports.__getValueSourceOfObject = exports.isValueSource = exports.__isLocalDateTimeValueSource = exports.__isLocalTimeValueSource = exports.__isLocalDateValueSource = exports.__isStringValueSource = exports.__isUuidValueType = exports.__isUuidValueSource = exports.__isBooleanValueType = exports.__isBooleanValueSource = exports.__mergeOptional = void 0; | ||
const symbols_1 = require("../utils/symbols"); | ||
function __mergeOptional(op1, op2) { | ||
// Always select the less strict option | ||
if (op1 === 'required') { | ||
return op2; | ||
} | ||
if (op1 === 'requiredInOptionalObject') { | ||
if (op2 === 'required') { | ||
return 'requiredInOptionalObject'; | ||
} | ||
else { | ||
return op2; | ||
} | ||
} | ||
if (op1 === 'originallyRequired') { | ||
if (op2 === 'required' || op2 === 'requiredInOptionalObject') { | ||
return 'originallyRequired'; | ||
} | ||
else { | ||
return op2; | ||
} | ||
} | ||
return 'optional'; | ||
} | ||
exports.__mergeOptional = __mergeOptional; | ||
function __isBooleanValueSource(valueSourcePrivate) { | ||
@@ -6,0 +30,0 @@ return valueSourcePrivate.__valueType === 'boolean'; |
{ | ||
"name": "ts-sql-query", | ||
"version": "1.61.0", | ||
"version": "1.62.0", | ||
"description": "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.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -26,1 +26,7 @@ import type { TypeAdapter } from "../TypeAdapter"; | ||
} | ||
export declare class FragmentFunctionBuilderMaybeOptional { | ||
definitions: Argument<any, any, any, any>[]; | ||
sqlBuilderSource: SqlBuilderSource; | ||
constructor(sqlBuilderSource: SqlBuilderSource, definitions: Argument<any, any, any, any>[]); | ||
as(impl: (...vs: AnyValueSource[]) => AnyValueSource): ((...args: any[]) => AnyValueSource); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FragmentFunctionBuilderIfValue = exports.FragmentFunctionBuilder = exports.FragmentQueryBuilder = void 0; | ||
exports.FragmentFunctionBuilderMaybeOptional = exports.FragmentFunctionBuilderIfValue = exports.FragmentFunctionBuilder = exports.FragmentQueryBuilder = void 0; | ||
const values_1 = require("../expressions/values"); | ||
@@ -72,1 +72,37 @@ const ValueSourceImpl_1 = require("../internal/ValueSourceImpl"); | ||
exports.FragmentFunctionBuilderIfValue = FragmentFunctionBuilderIfValue; | ||
class FragmentFunctionBuilderMaybeOptional { | ||
constructor(sqlBuilderSource, definitions) { | ||
this.sqlBuilderSource = sqlBuilderSource; | ||
this.definitions = definitions; | ||
} | ||
as(impl) { | ||
return (...args) => { | ||
let optionalType = 'required'; | ||
const newArgs = []; | ||
for (let i = 0, length = args.length; i < length; i++) { | ||
const arg = args[i]; | ||
let argOptionalType; | ||
if ((0, values_1.isValueSource)(arg)) { | ||
argOptionalType = (0, values_1.__getValueSourcePrivate)(arg).__optionalType; | ||
newArgs.push(arg); | ||
} | ||
else { | ||
if (this.sqlBuilderSource.__sqlBuilder._isValue(arg)) { | ||
argOptionalType = 'required'; | ||
} | ||
else { | ||
argOptionalType = 'optional'; | ||
} | ||
const definition = this.definitions[i]; | ||
const newArg = new ValueSourceImpl_1.SqlOperationConstValueSource(arg, definition.type, definition.typeName, definition.optionalType, definition.adapter); | ||
newArgs.push(newArg); | ||
} | ||
optionalType = (0, values_1.__mergeOptional)(optionalType, argOptionalType); | ||
} | ||
const result = impl.apply(undefined, newArgs); | ||
(0, values_1.__getValueSourcePrivate)(result).__optionalType = optionalType; | ||
return result; | ||
}; | ||
} | ||
} | ||
exports.FragmentFunctionBuilderMaybeOptional = FragmentFunctionBuilderMaybeOptional; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2586482
40569