Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/attributes/Attribute.mixins.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -10,6 +11,7 @@ import Attribute from './Attribute'

applyMixins(Attribute, [
AliasPredication,
ConcatPredication,
Expressions,
Math,
OrderPredications,
Expand Down
2 changes: 2 additions & 0 deletions src/attributes/Attribute.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -37,6 +38,7 @@ class Attribute {

interface Attribute
extends AliasPredication,
ConcatPredication,
Expressions,
Math,
OrderPredications,
Expand Down
2 changes: 1 addition & 1 deletion src/managers/SelectManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class SelectManager extends TreeManager<SelectStatement> {

if (typeof rel === 'string' || rel instanceof SQLLiteral) {
rel = new SQLLiteral(rel)
if (rel.value.length <= 0) {
if (rel.length <= 0) {
throw new EmptyJoinError()
}

Expand Down
7 changes: 7 additions & 0 deletions src/mixins/ConcatPredication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Concat from '../nodes/Concat'

export default abstract class ConcatPredication {
concat(other: any): Concat {
return new Concat(this, other)
}
}
5 changes: 0 additions & 5 deletions src/mixins/Predications.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/mixins/mod.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
8 changes: 7 additions & 1 deletion src/nodes/Case.mixins.ts
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion src/nodes/Case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -40,6 +41,10 @@ class Case extends Node {
}
}

interface Case extends AliasPredication, OrderPredications, Predications {}
interface Case
extends AliasPredication,
ConcatPredication,
OrderPredications,
Predications {}

export default Case
8 changes: 7 additions & 1 deletion src/nodes/Extract.mixins.ts
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion src/nodes/Extract.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -14,6 +15,10 @@ class Extract extends Unary {
}
}

interface Extract extends AliasPredication, Predications, WhenPredication {}
interface Extract
extends AliasPredication,
ConcatPredication,
Predications,
WhenPredication {}

export default Extract
3 changes: 2 additions & 1 deletion src/nodes/Grouping.mixins.ts
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion src/nodes/Grouping.ts
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/nodes/InfixOperation.mixins.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -10,6 +11,7 @@ import InfixOperation from './InfixOperation'

applyMixins(InfixOperation, [
AliasPredication,
ConcatPredication,
Expressions,
Math,
OrderPredications,
Expand Down
2 changes: 2 additions & 0 deletions src/nodes/InfixOperation.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -19,6 +20,7 @@ class InfixOperation extends Binary {

interface InfixOperation
extends AliasPredication,
ConcatPredication,
Expressions,
Math,
OrderPredications,
Expand Down
2 changes: 2 additions & 0 deletions src/nodes/SQLFunction.mixins.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ConcatPredication from '../mixins/ConcatPredication'
import OrderPredications from '../mixins/OrderPredications'
import Predications from '../mixins/Predications'
import WhenPredication from '../mixins/WhenPredication'
Expand All @@ -7,6 +8,7 @@ import applyMixins from '../mixins/applyMixins'
import SQLFunction from './SQLFunction'

applyMixins(SQLFunction, [
ConcatPredication,
OrderPredications,
Predications,
WhenPredication,
Expand Down
4 changes: 3 additions & 1 deletion src/nodes/SQLFunction.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -31,7 +32,8 @@ class SQLFunction extends Node {
}

interface SQLFunction
extends OrderPredications,
extends ConcatPredication,
OrderPredications,
Predications,
WhenPredication,
WindowPredication {}
Expand Down
16 changes: 1 addition & 15 deletions src/nodes/SQLLiteral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/nodes/UnaryOperation.mixins.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -10,6 +11,7 @@ import UnaryOperation from './UnaryOperation'

applyMixins(UnaryOperation, [
AliasPredication,
ConcatPredication,
Expressions,
Math,
OrderPredications,
Expand Down
2 changes: 2 additions & 0 deletions src/nodes/UnaryOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -21,6 +22,7 @@ class UnaryOperation extends Unary {

interface UnaryOperation
extends AliasPredication,
ConcatPredication,
Expressions,
Math,
OrderPredications,
Expand Down