|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import {WhereOperator} from '../../../lib/src/collection/Where.ts'
|
|
|
|
|
import RawValue from './RawValue.ts'
|
|
|
|
|
import {Select} from "./type/Select.ts";
|
|
|
|
|
|
|
|
|
|
export type FieldSet = string | string[]
|
|
|
|
|
export type QuerySource = string | { ref: QuerySource, alias: string }
|
|
|
|
@ -20,7 +21,7 @@ export type HavingGroup = WhereGroup
|
|
|
|
|
export type HavingStatement = HavingClause | HavingGroup
|
|
|
|
|
export type SQLHavingOperator = SQLWhereOperator
|
|
|
|
|
|
|
|
|
|
export type EscapedValue = string | number | boolean | Date | RawValue | EscapedValue[]
|
|
|
|
|
export type EscapedValue = string | number | boolean | Date | RawValue | EscapedValue[] | Select<any>
|
|
|
|
|
|
|
|
|
|
export type FieldValue = { field: string, value: EscapedValue }
|
|
|
|
|
export type FieldValueObject = { [field: string]: EscapedValue }
|
|
|
|
@ -76,7 +77,9 @@ export function isWhereStatement(something: any): something is WhereStatement {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function escape(value: EscapedValue): string {
|
|
|
|
|
if ( value instanceof RawValue ) {
|
|
|
|
|
if ( value instanceof Select ) {
|
|
|
|
|
return `(${value.sql(5)})`
|
|
|
|
|
} else if ( value instanceof RawValue ) {
|
|
|
|
|
return value.value
|
|
|
|
|
} else if ( Array.isArray(value) ) {
|
|
|
|
|
return `(${value.map(escape).join(',')})`
|
|
|
|
|