Skip to content

Commit

Permalink
bump to version 0.12.1
Browse files Browse the repository at this point in the history
fix migration to new query DSL
  • Loading branch information
darkxanter committed Feb 19, 2024
1 parent 66c4a9c commit 9d0bc5f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.12.1

Fix migration to new query DSL


# 0.12.0

### Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlin.code.style=official

group=io.github.darkxanter.exposed
version=0.12.0
version=0.12.1

kotlinVersion=1.9.22
dokkaVersion=1.9.10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ internal fun FileSpec.Builder.generateCrudRepository(tableDefinition: TableDefin
tableTypeName = tableTypeName,
listClassName = projection.className,
toFunctionName = projection.toFunctionListName,
sliceColumns = projection.columns,
selectColumns = projection.columns,
)
}

Expand Down Expand Up @@ -216,15 +216,15 @@ private fun TypeSpec.Builder.addFindFunction(
tableTypeName: TypeName,
listClassName: ClassName,
toFunctionName: String,
sliceColumns: List<ColumnDefinition> = emptyList(),
selectColumns: List<ColumnDefinition> = emptyList(),
) {
val toFun = "${toFunctionName}()"

val slice = if (sliceColumns.isNotEmpty())
sliceColumns.joinToString(",", prefix = ".slice(", postfix = ")") {
val select = if (selectColumns.isNotEmpty())
selectColumns.joinToString(",", prefix = "select(", postfix = ")") {
"$tableName.${it.name}"
}
else ""
else "selectAll()"

addFunction(name) {
returns(List::class.asClassName().parameterizedBy(listClassName))
Expand All @@ -241,9 +241,9 @@ private fun TypeSpec.Builder.addFindFunction(
addReturn()
transactionBlock {
beginControlFlow("if (where != null)")
addStatement("${tableName}${slice}.selectAll().where{where($tableName)}.apply{configure($tableName)}.$toFun")
addStatement("${tableName}.${select}.where{where($tableName)}.apply{configure($tableName)}.$toFun")
nextControlFlow("else")
addStatement("${tableName}${slice}.selectAll().apply{configure($tableName)}.$toFun")
addStatement("${tableName}.${select}.apply{configure($tableName)}.$toFun")
endControlFlow()
}
}
Expand Down

0 comments on commit 9d0bc5f

Please sign in to comment.