Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOPE-200 renamed extension functions #32

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ch.ergon.dope.resolvable.clause.model.DeleteWhereClause
import ch.ergon.dope.resolvable.clause.model.ReturningClause
import ch.ergon.dope.resolvable.expression.TypeExpression
import ch.ergon.dope.resolvable.expression.unaliased.type.Field
import ch.ergon.dope.resolvable.expression.unaliased.type.toNumberType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.validtype.ArrayType
import ch.ergon.dope.validtype.BooleanType
import ch.ergon.dope.validtype.NumberType
Expand All @@ -23,12 +23,12 @@ interface IDeleteOffsetClause : IDeleteReturningClause {

interface IDeleteLimitClause : IDeleteOffsetClause {
fun offset(numberExpression: TypeExpression<NumberType>) = DeleteOffsetClause(numberExpression, this)
fun offset(number: Number): DeleteOffsetClause = offset(number.toNumberType())
fun offset(number: Number): DeleteOffsetClause = offset(number.toDopeType())
}

interface IDeleteWhereClause : IDeleteLimitClause {
fun limit(numberExpression: TypeExpression<NumberType>) = DeleteLimitClause(numberExpression, this)
fun limit(number: Number): DeleteLimitClause = limit(number.toNumberType())
fun limit(number: Number): DeleteLimitClause = limit(number.toDopeType())
}

interface IDeleteUseKeysClause : IDeleteWhereClause {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ch.ergon.dope.resolvable.clause.model.UnnestClause
import ch.ergon.dope.resolvable.expression.AliasedExpression
import ch.ergon.dope.resolvable.expression.TypeExpression
import ch.ergon.dope.resolvable.expression.unaliased.type.Field
import ch.ergon.dope.resolvable.expression.unaliased.type.toNumberType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.resolvable.fromable.AliasedSelectClause
import ch.ergon.dope.resolvable.fromable.Bucket
import ch.ergon.dope.resolvable.fromable.Fromable
Expand All @@ -33,12 +33,12 @@ interface ISelectOffsetClause : Clause

interface ISelectLimitClause : ISelectOffsetClause {
fun offset(numberExpression: TypeExpression<NumberType>): SelectOffsetClause = SelectOffsetClause(numberExpression, this)
fun offset(number: Number): SelectOffsetClause = offset(number.toNumberType())
fun offset(number: Number): SelectOffsetClause = offset(number.toDopeType())
}

interface ISelectOrderByClause : ISelectLimitClause {
fun limit(numberExpression: TypeExpression<NumberType>): SelectLimitClause = SelectLimitClause(numberExpression, this)
fun limit(number: Number): SelectLimitClause = limit(number.toNumberType())
fun limit(number: Number): SelectLimitClause = limit(number.toDopeType())
}

interface ISelectGroupByClause : ISelectOrderByClause {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package ch.ergon.dope.resolvable.expression

import ch.ergon.dope.DopeQuery
import ch.ergon.dope.resolvable.expression.unaliased.type.toBooleanType
import ch.ergon.dope.resolvable.expression.unaliased.type.toNumberType
import ch.ergon.dope.resolvable.expression.unaliased.type.toStringType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.resolvable.formatToQueryStringWithSymbol
import ch.ergon.dope.validtype.ValidType

Expand All @@ -22,8 +20,8 @@ class AliasedExpression<T : ValidType>(

fun <T : ValidType> UnaliasedExpression<T>.alias(string: String): AliasedExpression<T> = AliasedExpression(this, string)

fun Number.alias(string: String) = this.toNumberType().alias(string)
fun Number.alias(string: String) = this.toDopeType().alias(string)

fun String.alias(string: String) = this.toStringType().alias(string)
fun String.alias(string: String) = this.toDopeType().alias(string)

fun Boolean.alias(string: String) = this.toBooleanType().alias(string)
fun Boolean.alias(string: String) = this.toDopeType().alias(string)
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class ArrayPrimitive<T : ValidType>(collection: Collection<TypeExpression<out T>
},
)

fun String.toStringType(): StringPrimitive = StringPrimitive(this)
fun String.toDopeType(): StringPrimitive = StringPrimitive(this)

fun Number.toNumberType(): NumberPrimitive = NumberPrimitive(this)
fun Number.toDopeType(): NumberPrimitive = NumberPrimitive(this)

fun Boolean.toBooleanType(): BooleanPrimitive = BooleanPrimitive(this)
fun Boolean.toDopeType(): BooleanPrimitive = BooleanPrimitive(this)

fun <T : ValidType> Collection<TypeExpression<out T>>.toArrayType() = ArrayPrimitive(this)
fun <T : ValidType> Collection<TypeExpression<out T>>.toDopeType() = ArrayPrimitive(this)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ch.ergon.dope.resolvable.expression.unaliased.type.arithmetic

import ch.ergon.dope.DopeQuery
import ch.ergon.dope.resolvable.expression.TypeExpression
import ch.ergon.dope.resolvable.expression.unaliased.type.toNumberType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.resolvable.operator.PrefixOperator
import ch.ergon.dope.validtype.NumberType

Expand All @@ -15,4 +15,4 @@ class NegationExpression(
fun neg(numberExpression: TypeExpression<NumberType>): NegationExpression =
NegationExpression(numberExpression)

fun neg(number: Number): NegationExpression = neg(number.toNumberType())
fun neg(number: Number): NegationExpression = neg(number.toDopeType())
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ch.ergon.dope.resolvable.expression.unaliased.type.arithmetic

import ch.ergon.dope.DopeQuery
import ch.ergon.dope.resolvable.expression.TypeExpression
import ch.ergon.dope.resolvable.expression.unaliased.type.toNumberType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.resolvable.formatToQueryStringWithBrackets
import ch.ergon.dope.resolvable.operator.InfixOperator
import ch.ergon.dope.validtype.NumberType
Expand Down Expand Up @@ -38,43 +38,43 @@ fun TypeExpression<NumberType>.mod(numberExpression: TypeExpression<NumberType>)
NumberInfixExpression(this, "%", numberExpression)

fun TypeExpression<NumberType>.add(number: Number): NumberInfixExpression =
add(number.toNumberType())
add(number.toDopeType())

fun Number.add(numberExpression: TypeExpression<NumberType>): NumberInfixExpression =
this.toNumberType().add(numberExpression)
this.toDopeType().add(numberExpression)

fun Number.add(number: Number): NumberInfixExpression =
this.toNumberType().add(number.toNumberType())
this.toDopeType().add(number.toDopeType())

fun TypeExpression<NumberType>.sub(number: Number): NumberInfixExpression =
sub(number.toNumberType())
sub(number.toDopeType())

fun Number.sub(numberExpression: TypeExpression<NumberType>): NumberInfixExpression =
this.toNumberType().sub(numberExpression)
this.toDopeType().sub(numberExpression)

fun Number.sub(number: Number): NumberInfixExpression =
this.toNumberType().sub(number.toNumberType())
this.toDopeType().sub(number.toDopeType())

fun TypeExpression<NumberType>.mul(number: Number): NumberInfixExpression =
mul(number.toNumberType())
mul(number.toDopeType())

fun Number.mul(numberExpression: TypeExpression<NumberType>): NumberInfixExpression =
this.toNumberType().mul(numberExpression)
this.toDopeType().mul(numberExpression)

fun Number.mul(number: Number): NumberInfixExpression =
this.toNumberType().mul(number.toNumberType())
this.toDopeType().mul(number.toDopeType())

fun TypeExpression<NumberType>.div(number: Number): NumberInfixExpression =
div(number.toNumberType())
div(number.toDopeType())

fun Number.div(numberExpression: TypeExpression<NumberType>): NumberInfixExpression =
this.toNumberType().div(numberExpression)
this.toDopeType().div(numberExpression)

fun TypeExpression<NumberType>.mod(number: Number): NumberInfixExpression =
mod(number.toNumberType())
mod(number.toDopeType())

fun Number.mod(numberExpression: TypeExpression<NumberType>): NumberInfixExpression =
this.toNumberType().mod(numberExpression)
this.toDopeType().mod(numberExpression)

fun Number.mod(number: Number): NumberInfixExpression =
this.toNumberType().mod(number.toNumberType())
this.toDopeType().mod(number.toDopeType())
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ch.ergon.dope.resolvable.expression.unaliased.type.logical

import ch.ergon.dope.DopeQuery
import ch.ergon.dope.resolvable.expression.TypeExpression
import ch.ergon.dope.resolvable.expression.unaliased.type.toBooleanType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.resolvable.operator.InfixOperator
import ch.ergon.dope.validtype.BooleanType

Expand All @@ -21,13 +21,13 @@ fun TypeExpression<BooleanType>.and(booleanExpression: TypeExpression<BooleanTyp
LogicalInfixExpression(this, "AND", booleanExpression)

fun TypeExpression<BooleanType>.or(boolean: Boolean): LogicalInfixExpression =
this.or(boolean.toBooleanType())
this.or(boolean.toDopeType())

fun Boolean.or(booleanExpression: TypeExpression<BooleanType>): LogicalInfixExpression =
this.toBooleanType().or(booleanExpression)
this.toDopeType().or(booleanExpression)

fun TypeExpression<BooleanType>.and(boolean: Boolean): LogicalInfixExpression =
this.and(boolean.toBooleanType())
this.and(boolean.toDopeType())

fun Boolean.and(booleanExpression: TypeExpression<BooleanType>): LogicalInfixExpression =
this.toBooleanType().and(booleanExpression)
this.toDopeType().and(booleanExpression)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ch.ergon.dope.resolvable.expression.unaliased.type.logical

import ch.ergon.dope.DopeQuery
import ch.ergon.dope.resolvable.expression.TypeExpression
import ch.ergon.dope.resolvable.expression.unaliased.type.toBooleanType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.resolvable.operator.PrefixOperator
import ch.ergon.dope.validtype.BooleanType

Expand All @@ -14,4 +14,4 @@ class NotExpression(

fun not(expression: TypeExpression<BooleanType>) = NotExpression(expression)

fun not(boolean: Boolean) = not(boolean.toBooleanType())
fun not(boolean: Boolean) = not(boolean.toDopeType())
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package ch.ergon.dope.resolvable.expression.unaliased.type.relational

import ch.ergon.dope.DopeQuery
import ch.ergon.dope.resolvable.expression.TypeExpression
import ch.ergon.dope.resolvable.expression.unaliased.type.toBooleanType
import ch.ergon.dope.resolvable.expression.unaliased.type.toNumberType
import ch.ergon.dope.resolvable.expression.unaliased.type.toStringType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.resolvable.operator.InfixOperator
import ch.ergon.dope.validtype.BooleanType
import ch.ergon.dope.validtype.NumberType
Expand All @@ -22,28 +20,28 @@ fun <T : ValidType> TypeExpression<T>.isEqualTo(right: TypeExpression<T>): Equal
EqualsExpression(this, right)

fun TypeExpression<NumberType>.isEqualTo(right: Number): EqualsExpression<NumberType> =
isEqualTo(right.toNumberType())
isEqualTo(right.toDopeType())

fun Number.isEqualTo(right: TypeExpression<NumberType>): EqualsExpression<NumberType> =
toNumberType().isEqualTo(right)
toDopeType().isEqualTo(right)

fun Number.isEqualTo(right: Number): EqualsExpression<NumberType> =
toNumberType().isEqualTo(right.toNumberType())
toDopeType().isEqualTo(right.toDopeType())

fun TypeExpression<StringType>.isEqualTo(right: String): EqualsExpression<StringType> =
isEqualTo(right.toStringType())
isEqualTo(right.toDopeType())

fun String.isEqualTo(right: TypeExpression<StringType>): EqualsExpression<StringType> =
toStringType().isEqualTo(right)
toDopeType().isEqualTo(right)

fun String.isEqualTo(right: String): EqualsExpression<StringType> =
toStringType().isEqualTo(right.toStringType())
toDopeType().isEqualTo(right.toDopeType())

fun TypeExpression<BooleanType>.isEqualTo(right: Boolean): EqualsExpression<BooleanType> =
isEqualTo(right.toBooleanType())
isEqualTo(right.toDopeType())

fun Boolean.isEqualTo(right: TypeExpression<BooleanType>): EqualsExpression<BooleanType> =
toBooleanType().isEqualTo(right)
toDopeType().isEqualTo(right)

fun Boolean.isEqualTo(right: Boolean): EqualsExpression<BooleanType> =
toBooleanType().isEqualTo(right.toBooleanType())
toDopeType().isEqualTo(right.toDopeType())
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package ch.ergon.dope.resolvable.expression.unaliased.type.relational

import ch.ergon.dope.DopeQuery
import ch.ergon.dope.resolvable.expression.TypeExpression
import ch.ergon.dope.resolvable.expression.unaliased.type.toNumberType
import ch.ergon.dope.resolvable.expression.unaliased.type.toStringType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.resolvable.operator.InfixOperator
import ch.ergon.dope.validtype.BooleanType
import ch.ergon.dope.validtype.ComparableType
Expand All @@ -21,19 +20,19 @@ fun <T : ComparableType> TypeExpression<T>.isGreaterOrEqualThan(right: TypeExpre
GreaterOrEqualThanExpression(this, right)

fun TypeExpression<NumberType>.isGreaterOrEqualThan(right: Number): GreaterOrEqualThanExpression<NumberType> =
isGreaterOrEqualThan(right.toNumberType())
isGreaterOrEqualThan(right.toDopeType())

fun Number.isGreaterOrEqualThan(right: TypeExpression<NumberType>): GreaterOrEqualThanExpression<NumberType> =
toNumberType().isGreaterOrEqualThan(right)
toDopeType().isGreaterOrEqualThan(right)

fun Number.isGreaterOrEqualThan(right: Number): GreaterOrEqualThanExpression<NumberType> =
toNumberType().isGreaterOrEqualThan(right.toNumberType())
toDopeType().isGreaterOrEqualThan(right.toDopeType())

fun TypeExpression<StringType>.isGreaterOrEqualThan(right: String): GreaterOrEqualThanExpression<StringType> =
isGreaterOrEqualThan(right.toStringType())
isGreaterOrEqualThan(right.toDopeType())

fun String.isGreaterOrEqualThan(right: TypeExpression<StringType>): GreaterOrEqualThanExpression<StringType> =
toStringType().isGreaterOrEqualThan(right)
toDopeType().isGreaterOrEqualThan(right)

fun String.isGreaterOrEqualThan(right: String): GreaterOrEqualThanExpression<StringType> =
toStringType().isGreaterOrEqualThan(right.toStringType())
toDopeType().isGreaterOrEqualThan(right.toDopeType())
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package ch.ergon.dope.resolvable.expression.unaliased.type.relational

import ch.ergon.dope.DopeQuery
import ch.ergon.dope.resolvable.expression.TypeExpression
import ch.ergon.dope.resolvable.expression.unaliased.type.toNumberType
import ch.ergon.dope.resolvable.expression.unaliased.type.toStringType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.resolvable.operator.InfixOperator
import ch.ergon.dope.validtype.BooleanType
import ch.ergon.dope.validtype.ComparableType
Expand All @@ -21,19 +20,19 @@ fun <T : ComparableType> TypeExpression<T>.isGreaterThan(right: TypeExpression<T
GreaterThanExpression(this, right)

fun TypeExpression<NumberType>.isGreaterThan(right: Number): GreaterThanExpression<NumberType> =
isGreaterThan(right.toNumberType())
isGreaterThan(right.toDopeType())

fun Number.isGreaterThan(right: TypeExpression<NumberType>): GreaterThanExpression<NumberType> =
this.toNumberType().isGreaterThan(right)
this.toDopeType().isGreaterThan(right)

fun Number.isGreaterThan(right: Number): GreaterThanExpression<NumberType> =
this.toNumberType().isGreaterThan(right.toNumberType())
this.toDopeType().isGreaterThan(right.toDopeType())

fun TypeExpression<StringType>.isGreaterThan(right: String): GreaterThanExpression<StringType> =
isGreaterThan(right.toStringType())
isGreaterThan(right.toDopeType())

fun String.isGreaterThan(right: TypeExpression<StringType>): GreaterThanExpression<StringType> =
this.toStringType().isGreaterThan(right)
this.toDopeType().isGreaterThan(right)

fun String.isGreaterThan(right: String): GreaterThanExpression<StringType> =
this.toStringType().isGreaterThan(right.toStringType())
this.toDopeType().isGreaterThan(right.toDopeType())
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package ch.ergon.dope.resolvable.expression.unaliased.type.relational

import ch.ergon.dope.DopeQuery
import ch.ergon.dope.resolvable.expression.TypeExpression
import ch.ergon.dope.resolvable.expression.unaliased.type.toArrayType
import ch.ergon.dope.resolvable.expression.unaliased.type.toBooleanType
import ch.ergon.dope.resolvable.expression.unaliased.type.toNumberType
import ch.ergon.dope.resolvable.expression.unaliased.type.toStringType
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType
import ch.ergon.dope.resolvable.operator.InfixOperator
import ch.ergon.dope.validtype.ArrayType
import ch.ergon.dope.validtype.BooleanType
Expand All @@ -24,22 +21,22 @@ fun <T : ValidType> TypeExpression<T>.inArray(array: TypeExpression<ArrayType<T>
InExpression(this, array)

fun Number.inArray(array: TypeExpression<ArrayType<NumberType>>): InExpression<NumberType> =
toNumberType().inArray(array)
toDopeType().inArray(array)

fun String.inArray(array: TypeExpression<ArrayType<StringType>>): InExpression<StringType> =
toStringType().inArray(array)
toDopeType().inArray(array)

fun Boolean.inArray(array: TypeExpression<ArrayType<BooleanType>>): InExpression<BooleanType> =
toBooleanType().inArray(array)
toDopeType().inArray(array)

fun <T : ValidType> TypeExpression<T>.inArray(array: Collection<TypeExpression<T>>): InExpression<T> =
this.inArray(array.toArrayType())
this.inArray(array.toDopeType())

fun Number.inArray(array: Collection<TypeExpression<NumberType>>): InExpression<NumberType> =
inArray(array.toArrayType())
inArray(array.toDopeType())

fun String.inArray(array: Collection<TypeExpression<StringType>>): InExpression<StringType> =
inArray(array.toArrayType())
inArray(array.toDopeType())

fun Boolean.inArray(array: Collection<TypeExpression<BooleanType>>): InExpression<BooleanType> =
inArray(array.toArrayType())
inArray(array.toDopeType())
Loading
Loading