Skip to content

Commit 2a8c9d8

Browse files
authored
Merge pull request #329 from jeffgbutler/general-cleanup
General cleanup
2 parents 32b9117 + 8b47424 commit 2a8c9d8

40 files changed

+845
-882
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2016-2020 the original author or authors.
2+
# Copyright 2016-2021 the original author or authors.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
3-
Copyright 2016-2020 the original author or authors.
3+
Copyright 2016-2021 the original author or authors.
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/JoinCollector.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,10 +38,12 @@ class JoinCollector {
3838

3939
fun and(column: BasicColumn, condition: JoinCondition) =
4040
apply {
41-
andJoinCriteria.add(JoinCriterion.Builder()
42-
.withConnector("and")
43-
.withJoinColumn(column)
44-
.withJoinCondition(condition)
45-
.build())
41+
andJoinCriteria.add(
42+
JoinCriterion.Builder()
43+
.withConnector("and")
44+
.withJoinColumn(column)
45+
.withJoinCondition(condition)
46+
.build()
47+
)
4648
}
4749
}

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/KotlinDeleteBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ import org.mybatis.dynamic.sql.util.Buildable
2222
typealias DeleteCompleter = KotlinDeleteBuilder.() -> Unit
2323

2424
class KotlinDeleteBuilder(private val dsl: DeleteDSL<DeleteModel>) :
25-
KotlinBaseBuilder<DeleteDSL<DeleteModel>, KotlinDeleteBuilder>(), Buildable<DeleteModel> {
25+
KotlinBaseBuilder<DeleteDSL<DeleteModel>, KotlinDeleteBuilder>(), Buildable<DeleteModel> {
2626

2727
override fun build(): DeleteModel = dsl.build()
2828

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/KotlinModelBuilderFunctions.kt

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/KotlinSelectBuilder.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,9 +18,9 @@ package org.mybatis.dynamic.sql.util.kotlin
1818
import org.mybatis.dynamic.sql.BasicColumn
1919
import org.mybatis.dynamic.sql.SortSpecification
2020
import org.mybatis.dynamic.sql.SqlTable
21+
import org.mybatis.dynamic.sql.select.QueryExpressionDSL
2122
import org.mybatis.dynamic.sql.select.SelectModel
2223
import org.mybatis.dynamic.sql.util.Buildable
23-
import org.mybatis.dynamic.sql.select.QueryExpressionDSL
2424

2525
typealias SelectCompleter = KotlinSelectBuilder.() -> Unit
2626

@@ -90,7 +90,9 @@ class KotlinSelectBuilder(private val fromGatherer: QueryExpressionDSL.FromGathe
9090
return dsl
9191
} catch (e: UninitializedPropertyAccessException) {
9292
throw UninitializedPropertyAccessException(
93-
"You must specify a \"from\" clause before any other clauses in a select statement", e)
93+
"You must specify a \"from\" clause before any other clauses in a select statement",
94+
e
95+
)
9496
}
9597
}
9698
}

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/KotlinConditions.kt renamed to src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/SqlElements.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright 2016-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
@file:Suppress("TooManyFunctions")
17+
package org.mybatis.dynamic.sql.util.kotlin.model
18+
19+
import org.mybatis.dynamic.sql.BasicColumn
20+
import org.mybatis.dynamic.sql.SqlBuilder
21+
import org.mybatis.dynamic.sql.SqlTable
22+
import org.mybatis.dynamic.sql.insert.BatchInsertDSL
23+
import org.mybatis.dynamic.sql.insert.GeneralInsertDSL
24+
import org.mybatis.dynamic.sql.insert.InsertDSL
25+
import org.mybatis.dynamic.sql.insert.MultiRowInsertDSL
26+
import org.mybatis.dynamic.sql.util.kotlin.BatchInsertCompleter
27+
import org.mybatis.dynamic.sql.util.kotlin.CountCompleter
28+
import org.mybatis.dynamic.sql.util.kotlin.DeleteCompleter
29+
import org.mybatis.dynamic.sql.util.kotlin.GeneralInsertCompleter
30+
import org.mybatis.dynamic.sql.util.kotlin.InsertCompleter
31+
import org.mybatis.dynamic.sql.util.kotlin.InsertSelectCompleter
32+
import org.mybatis.dynamic.sql.util.kotlin.KotlinCountBuilder
33+
import org.mybatis.dynamic.sql.util.kotlin.KotlinDeleteBuilder
34+
import org.mybatis.dynamic.sql.util.kotlin.KotlinInsertSelectSubQueryBuilder
35+
import org.mybatis.dynamic.sql.util.kotlin.KotlinSelectBuilder
36+
import org.mybatis.dynamic.sql.util.kotlin.KotlinUpdateBuilder
37+
import org.mybatis.dynamic.sql.util.kotlin.MultiRowInsertCompleter
38+
import org.mybatis.dynamic.sql.util.kotlin.SelectCompleter
39+
import org.mybatis.dynamic.sql.util.kotlin.UpdateCompleter
40+
41+
fun count(column: BasicColumn, completer: CountCompleter) =
42+
KotlinCountBuilder(SqlBuilder.countColumn(column)).apply(completer).build()
43+
44+
fun countDistinct(column: BasicColumn, completer: CountCompleter) =
45+
KotlinCountBuilder(SqlBuilder.countDistinctColumn(column)).apply(completer).build()
46+
47+
fun countFrom(table: SqlTable, completer: CountCompleter) =
48+
KotlinCountBuilder(SqlBuilder.countColumn(SqlBuilder.constant<Long>("*")))
49+
.from(table).apply(completer).build()
50+
51+
fun deleteFrom(table: SqlTable, completer: DeleteCompleter) =
52+
KotlinDeleteBuilder(SqlBuilder.deleteFrom(table)).apply(completer).build()
53+
54+
fun insertInto(table: SqlTable, completer: GeneralInsertCompleter) =
55+
GeneralInsertDSL.insertInto(table).apply(completer).build()
56+
57+
fun insertSelect(table: SqlTable, completer: InsertSelectCompleter) =
58+
with(KotlinInsertSelectSubQueryBuilder().apply(completer)) {
59+
SqlBuilder.insertInto(table)
60+
.withColumnList(columnList)
61+
.withSelectStatement(this)
62+
.build()
63+
}
64+
65+
fun <T> BatchInsertDSL.IntoGatherer<T>.into(table: SqlTable, completer: BatchInsertCompleter<T>) =
66+
into(table).apply(completer).build()
67+
68+
fun <T> InsertDSL.IntoGatherer<T>.into(table: SqlTable, completer: InsertCompleter<T>) =
69+
into(table).apply(completer).build()
70+
71+
fun <T> MultiRowInsertDSL.IntoGatherer<T>.into(table: SqlTable, completer: MultiRowInsertCompleter<T>) =
72+
into(table).apply(completer).build()
73+
74+
fun select(vararg columns: BasicColumn, completer: SelectCompleter) =
75+
select(columns.asList(), completer)
76+
77+
fun select(columns: List<BasicColumn>, completer: SelectCompleter) =
78+
KotlinSelectBuilder(SqlBuilder.select(columns)).apply(completer).build()
79+
80+
fun selectDistinct(vararg columns: BasicColumn, completer: SelectCompleter) =
81+
selectDistinct(columns.asList(), completer)
82+
83+
fun selectDistinct(columns: List<BasicColumn>, completer: SelectCompleter) =
84+
KotlinSelectBuilder(SqlBuilder.selectDistinct(columns)).apply(completer).build()
85+
86+
fun update(table: SqlTable, completer: UpdateCompleter) =
87+
KotlinUpdateBuilder(SqlBuilder.update(table)).apply(completer).build()

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/mybatis3/ProviderBuilderFunctions.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 the original author or authors.
2+
* Copyright 2016-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,16 +31,16 @@ import org.mybatis.dynamic.sql.util.kotlin.KotlinSelectBuilder
3131
import org.mybatis.dynamic.sql.util.kotlin.MultiRowInsertCompleter
3232
import org.mybatis.dynamic.sql.util.kotlin.SelectCompleter
3333
import org.mybatis.dynamic.sql.util.kotlin.UpdateCompleter
34-
import org.mybatis.dynamic.sql.util.kotlin.KotlinModelBuilderFunctions.count
35-
import org.mybatis.dynamic.sql.util.kotlin.KotlinModelBuilderFunctions.countDistinct
36-
import org.mybatis.dynamic.sql.util.kotlin.KotlinModelBuilderFunctions.countFrom
37-
import org.mybatis.dynamic.sql.util.kotlin.KotlinModelBuilderFunctions.deleteFrom
38-
import org.mybatis.dynamic.sql.util.kotlin.KotlinModelBuilderFunctions.insertInto
39-
import org.mybatis.dynamic.sql.util.kotlin.KotlinModelBuilderFunctions.insertSelect
40-
import org.mybatis.dynamic.sql.util.kotlin.KotlinModelBuilderFunctions.into
41-
import org.mybatis.dynamic.sql.util.kotlin.KotlinModelBuilderFunctions.select
42-
import org.mybatis.dynamic.sql.util.kotlin.KotlinModelBuilderFunctions.selectDistinct
43-
import org.mybatis.dynamic.sql.util.kotlin.KotlinModelBuilderFunctions.update
34+
import org.mybatis.dynamic.sql.util.kotlin.model.count
35+
import org.mybatis.dynamic.sql.util.kotlin.model.countDistinct
36+
import org.mybatis.dynamic.sql.util.kotlin.model.countFrom
37+
import org.mybatis.dynamic.sql.util.kotlin.model.deleteFrom
38+
import org.mybatis.dynamic.sql.util.kotlin.model.insertInto
39+
import org.mybatis.dynamic.sql.util.kotlin.model.insertSelect
40+
import org.mybatis.dynamic.sql.util.kotlin.model.into
41+
import org.mybatis.dynamic.sql.util.kotlin.model.select
42+
import org.mybatis.dynamic.sql.util.kotlin.model.selectDistinct
43+
import org.mybatis.dynamic.sql.util.kotlin.model.update
4444

4545
fun count(column: BasicColumn, completer: CountCompleter) =
4646
count(column, completer).render(RenderingStrategies.MYBATIS3)

0 commit comments

Comments
 (0)