Skip to content

Commit 8a86603

Browse files
committed
Docs for concat
1 parent 0431105 commit 8a86603

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ The pull request for this change is ([#550](https://github.com/mybatis/mybatis-d
5151
algorithm. Also deprecated the constructors on SqlTable that accept Suppliers for table name - this creates an
5252
effectively mutable object and goes against the principles of immutability that we strive for in the library.
5353
([#572](https://github.com/mybatis/mybatis-dynamic-sql/pull/572))
54-
55-
54+
5. Add `SqlBuilder.concat` and the equivalent in Kotlin. This is a concatenate function that works on more databases.
5655

5756
## Release 1.4.1 - October 7, 2022
5857

src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,30 @@ static <T> Subtract<T> subtract(BindableColumn<T> firstColumn, BasicColumn secon
489489
return Subtract.of(firstColumn, secondColumn, subsequentColumns);
490490
}
491491

492+
/**
493+
* Concatenate function that renders as "(x || y || z)". This will not work on some
494+
* databases like MySql. In that case, use {@link SqlBuilder#concat(BindableColumn, BasicColumn...)}
495+
*
496+
* @param firstColumn first column
497+
* @param secondColumn second column
498+
* @param subsequentColumns subsequent columns
499+
* @return a Concatenate instance
500+
* @param <T> type of column
501+
*/
492502
static <T> Concatenate<T> concatenate(BindableColumn<T> firstColumn, BasicColumn secondColumn,
493503
BasicColumn... subsequentColumns) {
494504
return Concatenate.concatenate(firstColumn, secondColumn, subsequentColumns);
495505
}
496506

507+
/**
508+
* Concatenate function that renders as "concat(x, y, z)". This version works on more databases
509+
* than {@link SqlBuilder#concatenate(BindableColumn, BasicColumn, BasicColumn...)}
510+
*
511+
* @param firstColumn first column
512+
* @param subsequentColumns subsequent columns
513+
* @return a Concat instance
514+
* @param <T> type of column
515+
*/
497516
static <T> Concat<T> concat(BindableColumn<T> firstColumn, BasicColumn... subsequentColumns) {
498517
return Concat.concat(firstColumn, subsequentColumns);
499518
}

src/main/java/org/mybatis/dynamic/sql/select/function/OperatorFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected OperatorFunction<T> copy() {
5050
public String renderWithTableAlias(TableAliasCalculator tableAliasCalculator) {
5151
String paddedOperator = " " + operator + " "; //$NON-NLS-1$ //$NON-NLS-2$
5252

53-
// note - the cast below is added for a type inference issues in some compilers
53+
// note - the cast below is added for type inference issues in some compilers
5454
return Stream.of(Stream.of((BasicColumn) column), Stream.of(secondColumn), subsequentColumns.stream())
5555
.flatMap(Function.identity())
5656
.map(column -> column.renderWithTableAlias(tableAliasCalculator))

0 commit comments

Comments
 (0)