Skip to content

Commit cee4884

Browse files
committed
Consistently use "row" instead of "record" with inserts
1 parent 6ac3110 commit cee4884

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

src/main/java/org/mybatis/dynamic/sql/insert/render/BatchInsertRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private BatchInsertRenderer(Builder<T> builder) {
3535
}
3636

3737
public BatchInsert<T> render() {
38-
BatchValuePhraseVisitor visitor = new BatchValuePhraseVisitor(renderingStrategy, "record"); //$NON-NLS-1$)
38+
BatchValuePhraseVisitor visitor = new BatchValuePhraseVisitor(renderingStrategy, "row"); //$NON-NLS-1$)
3939
List<FieldAndValue> fieldsAndValues = model
4040
.mapColumnMappings(m -> m.accept(visitor))
4141
.collect(Collectors.toList());

src/main/java/org/mybatis/dynamic/sql/insert/render/ValuePhraseVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ public Optional<FieldAndValue> visit(PropertyWhenPresentMapping mapping) {
7373

7474
private String calculateJdbcPlaceholder(SqlColumn<?> column, String parameterName) {
7575
return column.renderingStrategy().orElse(renderingStrategy)
76-
.getFormattedJdbcPlaceholder(column, "record", parameterName); //$NON-NLS-1$
76+
.getFormattedJdbcPlaceholder(column, "row", parameterName); //$NON-NLS-1$
7777
}
7878
}

src/test/java/examples/custom_render/CustomRenderingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ void testInsertRecord() {
102102
.render(RenderingStrategies.MYBATIS3);
103103

104104
String expected = "insert into JsonTest (id, description, info) "
105-
+ "values (#{record.id,jdbcType=INTEGER}, #{record.description,jdbcType=VARCHAR}, "
106-
+ "#{record.info,jdbcType=VARCHAR}::json)";
105+
+ "values (#{row.id,jdbcType=INTEGER}, #{row.description,jdbcType=VARCHAR}, "
106+
+ "#{row.info,jdbcType=VARCHAR}::json)";
107107

108108
assertThat(insertStatement.getInsertStatement()).isEqualTo(expected);
109109

src/test/java/org/mybatis/dynamic/sql/insert/InsertStatementTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void testFullInsertStatementBuilder() {
5252

5353
String expectedStatement = "insert into foo "
5454
+ "(id, first_name, last_name, occupation) "
55-
+ "values (#{record.id,jdbcType=INTEGER}, #{record.firstName,jdbcType=VARCHAR}, #{record.lastName,jdbcType=VARCHAR}, #{record.occupation,jdbcType=VARCHAR})";
55+
+ "values (#{row.id,jdbcType=INTEGER}, #{row.firstName,jdbcType=VARCHAR}, #{row.lastName,jdbcType=VARCHAR}, #{row.occupation,jdbcType=VARCHAR})";
5656

5757
assertThat(insertStatement.getInsertStatement()).isEqualTo(expectedStatement);
5858
}
@@ -72,7 +72,7 @@ void testInsertStatementBuilderWithNulls() {
7272
.render(RenderingStrategies.MYBATIS3);
7373

7474
String expected = "insert into foo (id, first_name, last_name, occupation) "
75-
+ "values (#{record.id,jdbcType=INTEGER}, #{record.firstName,jdbcType=VARCHAR}, #{record.lastName,jdbcType=VARCHAR}, null)";
75+
+ "values (#{row.id,jdbcType=INTEGER}, #{row.firstName,jdbcType=VARCHAR}, #{row.lastName,jdbcType=VARCHAR}, null)";
7676
assertThat(insertStatement.getInsertStatement()).isEqualTo(expected);
7777
}
7878

@@ -91,7 +91,7 @@ void testInsertStatementBuilderWithConstants() {
9191
.render(RenderingStrategies.MYBATIS3);
9292

9393
String expected = "insert into foo (id, first_name, last_name, occupation) "
94-
+ "values (3, #{record.firstName,jdbcType=VARCHAR}, #{record.lastName,jdbcType=VARCHAR}, 'Y')";
94+
+ "values (3, #{row.firstName,jdbcType=VARCHAR}, #{row.lastName,jdbcType=VARCHAR}, 'Y')";
9595
assertThat(insertStatement.getInsertStatement()).isEqualTo(expected);
9696
}
9797

@@ -111,7 +111,7 @@ void testSelectiveInsertStatementBuilder() {
111111
.render(RenderingStrategies.MYBATIS3);
112112

113113
String expected = "insert into foo (last_name, occupation) "
114-
+ "values (#{record.lastName,jdbcType=VARCHAR}, #{record.occupation,jdbcType=VARCHAR})";
114+
+ "values (#{row.lastName,jdbcType=VARCHAR}, #{row.occupation,jdbcType=VARCHAR})";
115115
assertThat(insertStatement.getInsertStatement()).isEqualTo(expected);
116116
}
117117

src/test/java/org/mybatis/dynamic/sql/mybatis3/InsertStatementTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ void testFullInsertStatementBuilder() {
4949
.render(RenderingStrategies.MYBATIS3);
5050

5151
String expected = "insert into foo (id, first_name, last_name, occupation) "
52-
+ "values (#{record.id,jdbcType=INTEGER}, "
53-
+ "#{record.firstName,jdbcType=VARCHAR}, " + "#{record.lastName,jdbcType=VARCHAR}, "
54-
+ "#{record.occupation,jdbcType=VARCHAR})";
52+
+ "values (#{row.id,jdbcType=INTEGER}, "
53+
+ "#{row.firstName,jdbcType=VARCHAR}, " + "#{row.lastName,jdbcType=VARCHAR}, "
54+
+ "#{row.occupation,jdbcType=VARCHAR})";
5555
assertThat(insertStatement.getInsertStatement()).isEqualTo(expected);
5656
}
5757

@@ -71,8 +71,8 @@ void testSelectiveInsertStatementBuilder() {
7171
.render(RenderingStrategies.MYBATIS3);
7272

7373
String expected = "insert into foo (last_name, occupation) "
74-
+ "values (#{record.lastName,jdbcType=VARCHAR}, "
75-
+ "#{record.occupation,jdbcType=VARCHAR})";
74+
+ "values (#{row.lastName,jdbcType=VARCHAR}, "
75+
+ "#{row.occupation,jdbcType=VARCHAR})";
7676
assertThat(insertStatement.getInsertStatement()).isEqualTo(expected);
7777
}
7878

src/test/kotlin/examples/kotlin/mybatis3/custom/render/KCustomRenderingTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ class KCustomRenderingTest {
9090
map(info) toProperty "info"
9191
}
9292
val expected = "insert into JsonTest (id, description, info) " +
93-
"values (#{record.id,jdbcType=INTEGER}, #{record.description,jdbcType=VARCHAR}, " +
94-
"#{record.info,jdbcType=VARCHAR}::json)"
93+
"values (#{row.id,jdbcType=INTEGER}, #{row.description,jdbcType=VARCHAR}, " +
94+
"#{row.info,jdbcType=VARCHAR}::json)"
9595
assertThat(insertStatement.insertStatement).isEqualTo(expected)
9696
var rows = mapper.insert(insertStatement)
9797
assertThat(rows).isEqualTo(1)

src/test/kotlin/examples/kotlin/mybatis3/general/GeneralKotlinTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,13 @@ class GeneralKotlinTest {
312312
val expected =
313313
"insert into Person (id, first_name, last_name, birth_date, employed, occupation, address_id) " +
314314
"values " +
315-
"(#{record.id,jdbcType=INTEGER}, #{record.firstName,jdbcType=VARCHAR}, " +
316-
"#{record.lastName,jdbcType=VARCHAR," +
315+
"(#{row.id,jdbcType=INTEGER}, #{row.firstName,jdbcType=VARCHAR}, " +
316+
"#{row.lastName,jdbcType=VARCHAR," +
317317
"typeHandler=examples.kotlin.mybatis3.canonical.LastNameTypeHandler}, " +
318-
"#{record.birthDate,jdbcType=DATE}, " +
319-
"#{record.employed,jdbcType=VARCHAR," +
318+
"#{row.birthDate,jdbcType=DATE}, " +
319+
"#{row.employed,jdbcType=VARCHAR," +
320320
"typeHandler=examples.kotlin.mybatis3.canonical.YesNoTypeHandler}, " +
321-
"#{record.occupation,jdbcType=VARCHAR}, #{record.addressId,jdbcType=INTEGER})"
321+
"#{row.occupation,jdbcType=VARCHAR}, #{row.addressId,jdbcType=INTEGER})"
322322

323323
assertThat(insertStatement.insertStatement).isEqualTo(expected)
324324

0 commit comments

Comments
 (0)