Skip to content

Commit

Permalink
DOPE-244: update SubstringExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
jansigi committed Aug 29, 2024
1 parent 734e4e2 commit 29f7573
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ch.ergon.dope.validtype.StringType
class SubstringExpression(
private val inStr: TypeExpression<StringType>,
private val startPos: Int,
private val length: Int,
private val length: Int? = null,
) : TypeExpression<StringType>, FunctionOperator {
override fun toDopeQuery(manager: DopeQueryManager): DopeQuery {
val inStrDopeQuery = inStr.toDopeQuery(manager)
Expand All @@ -19,13 +19,13 @@ class SubstringExpression(
symbol = "SUBSTR",
inStrDopeQuery,
startPos.toDopeType().toDopeQuery(manager),
length.toDopeType().toDopeQuery(manager),
length?.toDopeType()?.toDopeQuery(manager),
),
parameters = inStrDopeQuery.parameters,
)
}
}

fun substr(inStr: TypeExpression<StringType>, startPos: Int, length: Int) = SubstringExpression(inStr, startPos, length)
fun substr(inStr: TypeExpression<StringType>, startPos: Int, length: Int? = null) = SubstringExpression(inStr, startPos, length)

fun substr(inStr: String, startPos: Int, length: Int = inStr.length) = substr(inStr.toDopeType(), startPos, length)
fun substr(inStr: String, startPos: Int, length: Int? = null) = substr(inStr.toDopeType(), startPos, length)

0 comments on commit 29f7573

Please sign in to comment.