diff --git a/src/attributes/Attribute.mixins.ts b/src/attributes/Attribute.mixins.ts index dd64e435..aebb3f40 100644 --- a/src/attributes/Attribute.mixins.ts +++ b/src/attributes/Attribute.mixins.ts @@ -1,4 +1,5 @@ import AliasPredication from '../mixins/AliasPredication' +import ConcatPredication from '../mixins/ConcatPredication' import Expressions from '../mixins/Expressions' import Math from '../mixins/Math' import OrderPredications from '../mixins/OrderPredications' @@ -10,6 +11,7 @@ import Attribute from './Attribute' applyMixins(Attribute, [ AliasPredication, + ConcatPredication, Expressions, Math, OrderPredications, diff --git a/src/attributes/Attribute.ts b/src/attributes/Attribute.ts index 07e3dfbd..1b01bc5f 100644 --- a/src/attributes/Attribute.ts +++ b/src/attributes/Attribute.ts @@ -1,6 +1,7 @@ import type Relation from '../interfaces/Relation' import type AliasPredication from '../mixins/AliasPredication' +import type ConcatPredication from '../mixins/ConcatPredication' import type Expressions from '../mixins/Expressions' import type Math from '../mixins/Math' import type OrderPredications from '../mixins/OrderPredications' @@ -37,6 +38,7 @@ class Attribute { interface Attribute extends AliasPredication, + ConcatPredication, Expressions, Math, OrderPredications, diff --git a/src/managers/SelectManager.ts b/src/managers/SelectManager.ts index 73560b1d..597e6db7 100644 --- a/src/managers/SelectManager.ts +++ b/src/managers/SelectManager.ts @@ -195,7 +195,7 @@ class SelectManager extends TreeManager { if (typeof rel === 'string' || rel instanceof SQLLiteral) { rel = new SQLLiteral(rel) - if (rel.value.length <= 0) { + if (rel.length <= 0) { throw new EmptyJoinError() } diff --git a/src/mixins/ConcatPredication.ts b/src/mixins/ConcatPredication.ts new file mode 100644 index 00000000..3ca6a5fb --- /dev/null +++ b/src/mixins/ConcatPredication.ts @@ -0,0 +1,7 @@ +import Concat from '../nodes/Concat' + +export default abstract class ConcatPredication { + concat(other: any): Concat { + return new Concat(this, other) + } +} diff --git a/src/mixins/Predications.ts b/src/mixins/Predications.ts index f435d5af..8f65bb14 100644 --- a/src/mixins/Predications.ts +++ b/src/mixins/Predications.ts @@ -1,6 +1,5 @@ import And from '../nodes/And' import Between from '../nodes/Between' -import Concat from '../nodes/Concat' import DoesNotMatch from '../nodes/DoesNotMatch' import Equality from '../nodes/Equality' import GreaterThan from '../nodes/GreaterThan' @@ -55,10 +54,6 @@ export default abstract class Predications { return others.map((v) => this.quotedNode(v)) } - concat(other: any): Concat { - return new Concat(this, other) - } - doesNotMatch( other: any, escape: any = null, diff --git a/src/mixins/mod.ts b/src/mixins/mod.ts index b7a12613..0e2cf9dd 100644 --- a/src/mixins/mod.ts +++ b/src/mixins/mod.ts @@ -1,4 +1,5 @@ export { default as AliasPredication } from './AliasPredication' +export { default as ConcatPredication } from './ConcatPredication' export { default as Expressions } from './Expressions' export { default as FactoryMethods } from './FactoryMethods' export { default as Math } from './Math' diff --git a/src/nodes/Case.mixins.ts b/src/nodes/Case.mixins.ts index 03f25837..495db4b1 100644 --- a/src/nodes/Case.mixins.ts +++ b/src/nodes/Case.mixins.ts @@ -1,10 +1,16 @@ import AliasPredication from '../mixins/AliasPredication' +import ConcatPredication from '../mixins/ConcatPredication' import OrderPredications from '../mixins/OrderPredications' import Predications from '../mixins/Predications' import applyMixins from '../mixins/applyMixins' import Case from './Case' -applyMixins(Case, [AliasPredication, OrderPredications, Predications]) +applyMixins(Case, [ + AliasPredication, + ConcatPredication, + OrderPredications, + Predications, +]) export default Case diff --git a/src/nodes/Case.ts b/src/nodes/Case.ts index 77d9e686..047beb20 100644 --- a/src/nodes/Case.ts +++ b/src/nodes/Case.ts @@ -4,6 +4,7 @@ import When from './When' import buildQuoted from './buildQuoted' import type AliasPredication from '../mixins/AliasPredication' +import type ConcatPredication from '../mixins/ConcatPredication' import type OrderPredications from '../mixins/OrderPredications' import type Predications from '../mixins/Predications' @@ -40,6 +41,10 @@ class Case extends Node { } } -interface Case extends AliasPredication, OrderPredications, Predications {} +interface Case + extends AliasPredication, + ConcatPredication, + OrderPredications, + Predications {} export default Case diff --git a/src/nodes/Extract.mixins.ts b/src/nodes/Extract.mixins.ts index 521b167a..de89993f 100644 --- a/src/nodes/Extract.mixins.ts +++ b/src/nodes/Extract.mixins.ts @@ -1,10 +1,16 @@ import AliasPredication from '../mixins/AliasPredication' +import ConcatPredication from '../mixins/ConcatPredication' import Predications from '../mixins/Predications' import WhenPredication from '../mixins/WhenPredication' import applyMixins from '../mixins/applyMixins' import Extract from './Extract' -applyMixins(Extract, [AliasPredication, Predications, WhenPredication]) +applyMixins(Extract, [ + AliasPredication, + ConcatPredication, + Predications, + WhenPredication, +]) export default Extract diff --git a/src/nodes/Extract.ts b/src/nodes/Extract.ts index 593190b1..155a30e7 100644 --- a/src/nodes/Extract.ts +++ b/src/nodes/Extract.ts @@ -1,6 +1,7 @@ import Unary from './Unary' import type AliasPredication from '../mixins/AliasPredication' +import type ConcatPredication from '../mixins/ConcatPredication' import type Predications from '../mixins/Predications' import type WhenPredication from '../mixins/WhenPredication' @@ -14,6 +15,10 @@ class Extract extends Unary { } } -interface Extract extends AliasPredication, Predications, WhenPredication {} +interface Extract + extends AliasPredication, + ConcatPredication, + Predications, + WhenPredication {} export default Extract diff --git a/src/nodes/Grouping.mixins.ts b/src/nodes/Grouping.mixins.ts index e6e5b304..9b7ce8d2 100644 --- a/src/nodes/Grouping.mixins.ts +++ b/src/nodes/Grouping.mixins.ts @@ -1,9 +1,10 @@ +import ConcatPredication from '../mixins/ConcatPredication' import Predications from '../mixins/Predications' import WhenPredication from '../mixins/WhenPredication' import applyMixins from '../mixins/applyMixins' import Grouping from './Grouping' -applyMixins(Grouping, [Predications, WhenPredication]) +applyMixins(Grouping, [ConcatPredication, Predications, WhenPredication]) export default Grouping diff --git a/src/nodes/Grouping.ts b/src/nodes/Grouping.ts index ae64795e..cfbd3524 100644 --- a/src/nodes/Grouping.ts +++ b/src/nodes/Grouping.ts @@ -1,10 +1,11 @@ import Unary from './Unary' +import type ConcatPredication from '../mixins/ConcatPredication' import type Predications from '../mixins/Predications' import type WhenPredication from '../mixins/WhenPredication' class Grouping extends Unary {} -interface Grouping extends Predications, WhenPredication {} +interface Grouping extends ConcatPredication, Predications, WhenPredication {} export default Grouping diff --git a/src/nodes/InfixOperation.mixins.ts b/src/nodes/InfixOperation.mixins.ts index 08bffb37..f9ac83eb 100644 --- a/src/nodes/InfixOperation.mixins.ts +++ b/src/nodes/InfixOperation.mixins.ts @@ -1,4 +1,5 @@ import AliasPredication from '../mixins/AliasPredication' +import ConcatPredication from '../mixins/ConcatPredication' import Expressions from '../mixins/Expressions' import Math from '../mixins/Math' import OrderPredications from '../mixins/OrderPredications' @@ -10,6 +11,7 @@ import InfixOperation from './InfixOperation' applyMixins(InfixOperation, [ AliasPredication, + ConcatPredication, Expressions, Math, OrderPredications, diff --git a/src/nodes/InfixOperation.ts b/src/nodes/InfixOperation.ts index fbba3e2b..14eff551 100644 --- a/src/nodes/InfixOperation.ts +++ b/src/nodes/InfixOperation.ts @@ -1,6 +1,7 @@ import Binary from './Binary' import type AliasPredication from '../mixins/AliasPredication' +import type ConcatPredication from '../mixins/ConcatPredication' import type Expressions from '../mixins/Expressions' import type Math from '../mixins/Math' import type OrderPredications from '../mixins/OrderPredications' @@ -19,6 +20,7 @@ class InfixOperation extends Binary { interface InfixOperation extends AliasPredication, + ConcatPredication, Expressions, Math, OrderPredications, diff --git a/src/nodes/SQLFunction.mixins.ts b/src/nodes/SQLFunction.mixins.ts index d45e141c..3d7f570c 100644 --- a/src/nodes/SQLFunction.mixins.ts +++ b/src/nodes/SQLFunction.mixins.ts @@ -1,3 +1,4 @@ +import ConcatPredication from '../mixins/ConcatPredication' import OrderPredications from '../mixins/OrderPredications' import Predications from '../mixins/Predications' import WhenPredication from '../mixins/WhenPredication' @@ -7,6 +8,7 @@ import applyMixins from '../mixins/applyMixins' import SQLFunction from './SQLFunction' applyMixins(SQLFunction, [ + ConcatPredication, OrderPredications, Predications, WhenPredication, diff --git a/src/nodes/SQLFunction.ts b/src/nodes/SQLFunction.ts index b411dbb3..a04fae36 100644 --- a/src/nodes/SQLFunction.ts +++ b/src/nodes/SQLFunction.ts @@ -1,6 +1,7 @@ import Node from './Node' import SQLLiteral from './SQLLiteral' +import type ConcatPredication from '../mixins/ConcatPredication' import type OrderPredications from '../mixins/OrderPredications' import type Predications from '../mixins/Predications' import type WhenPredication from '../mixins/WhenPredication' @@ -31,7 +32,8 @@ class SQLFunction extends Node { } interface SQLFunction - extends OrderPredications, + extends ConcatPredication, + OrderPredications, Predications, WhenPredication, WindowPredication {} diff --git a/src/nodes/SQLLiteral.ts b/src/nodes/SQLLiteral.ts index eb90dcac..20a7b52b 100644 --- a/src/nodes/SQLLiteral.ts +++ b/src/nodes/SQLLiteral.ts @@ -4,21 +4,7 @@ import type OrderPredications from '../mixins/OrderPredications' import type Predications from '../mixins/Predications' import type WhenPredication from '../mixins/WhenPredication' -class SQLLiteral { - public value: string - - constructor(value: string | SQLLiteral) { - if (value instanceof SQLLiteral) { - this.value = value.value - } else { - this.value = value - } - } - - toString(): string { - return this.value - } -} +class SQLLiteral extends String {} interface SQLLiteral extends AliasPredication, diff --git a/src/nodes/UnaryOperation.mixins.ts b/src/nodes/UnaryOperation.mixins.ts index 31d06fcf..582b28c5 100644 --- a/src/nodes/UnaryOperation.mixins.ts +++ b/src/nodes/UnaryOperation.mixins.ts @@ -1,4 +1,5 @@ import AliasPredication from '../mixins/AliasPredication' +import ConcatPredication from '../mixins/ConcatPredication' import Expressions from '../mixins/Expressions' import Math from '../mixins/Math' import OrderPredications from '../mixins/OrderPredications' @@ -10,6 +11,7 @@ import UnaryOperation from './UnaryOperation' applyMixins(UnaryOperation, [ AliasPredication, + ConcatPredication, Expressions, Math, OrderPredications, diff --git a/src/nodes/UnaryOperation.ts b/src/nodes/UnaryOperation.ts index 5d7ed31e..eb9cd5a4 100644 --- a/src/nodes/UnaryOperation.ts +++ b/src/nodes/UnaryOperation.ts @@ -3,6 +3,7 @@ import Unary from './Unary' import type Attribute from '../attributes/Attribute' import type AliasPredication from '../mixins/AliasPredication' +import type ConcatPredication from '../mixins/ConcatPredication' import type Expressions from '../mixins/Expressions' import type Math from '../mixins/Math' import type OrderPredications from '../mixins/OrderPredications' @@ -21,6 +22,7 @@ class UnaryOperation extends Unary { interface UnaryOperation extends AliasPredication, + ConcatPredication, Expressions, Math, OrderPredications,