Skip to content

Commit 8dce8ad

Browse files
committed
#73 - Polishing.
Switch license header URLs to HTTPS. Rebase onto master.
1 parent cd28c65 commit 8dce8ad

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

src/main/java/org/springframework/data/r2dbc/function/DefaultReactiveDataAccessStrategy.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.OptionalLong;
2626
import java.util.Set;
2727
import java.util.function.BiFunction;
28+
import java.util.function.Function;
2829

2930
import org.springframework.dao.InvalidDataAccessResourceUsageException;
3031
import org.springframework.data.convert.CustomConversions.StoreConversions;
@@ -47,12 +48,14 @@
4748
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
4849
import org.springframework.data.relational.core.sql.Expression;
4950
import org.springframework.data.relational.core.sql.OrderByField;
51+
import org.springframework.data.relational.core.sql.Select;
5052
import org.springframework.data.relational.core.sql.SelectBuilder.SelectFromAndOrderBy;
5153
import org.springframework.data.relational.core.sql.StatementBuilder;
5254
import org.springframework.data.relational.core.sql.Table;
5355
import org.springframework.data.relational.core.sql.render.NamingStrategies;
5456
import org.springframework.data.relational.core.sql.render.RenderContext;
5557
import org.springframework.data.relational.core.sql.render.RenderNamingStrategy;
58+
import org.springframework.data.relational.core.sql.render.SelectRenderContext;
5659
import org.springframework.lang.Nullable;
5760
import org.springframework.util.Assert;
5861
import org.springframework.util.ClassUtils;
@@ -121,6 +124,21 @@ public DefaultReactiveDataAccessStrategy(Dialect dialect, R2dbcConverter convert
121124
public RenderNamingStrategy getNamingStrategy() {
122125
return NamingStrategies.asIs();
123126
}
127+
128+
@Override
129+
public SelectRenderContext getSelect() {
130+
return new SelectRenderContext() {
131+
@Override
132+
public Function<Select, ? extends CharSequence> afterSelectList() {
133+
return it -> "";
134+
}
135+
136+
@Override
137+
public Function<Select, ? extends CharSequence> afterOrderBy(boolean hasOrderBy) {
138+
return it -> "";
139+
}
140+
};
141+
}
124142
};
125143

126144
this.statements = new DefaultStatementFactory(this.dialect, renderContext);
@@ -238,7 +256,7 @@ public String getTableName(Class<?> type) {
238256
return getRequiredPersistentEntity(type).getTableName();
239257
}
240258

241-
/*
259+
/*
242260
* (non-Javadoc)
243261
* @see org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy#getStatements()
244262
*/
@@ -295,6 +313,7 @@ public String select(String tableName, Set<String> columns, Sort sort, Pageable
295313
offset = OptionalLong.of(page.getOffset());
296314
}
297315

316+
// See https://github.com/spring-projects/spring-data-r2dbc/issues/55
298317
return StatementRenderUtil.render(selectBuilder.build(), limit, offset, this.dialect);
299318
}
300319

src/main/java/org/springframework/data/r2dbc/function/DefaultStatementFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,

src/main/java/org/springframework/data/r2dbc/function/PreparedOperation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,

src/main/java/org/springframework/data/r2dbc/function/StatementFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,

src/main/java/org/springframework/data/r2dbc/support/StatementRenderUtil.java

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public static String render(Select select, OptionalLong limit, OptionalLong offs
4343
String sql = SqlRenderer.toString(select);
4444

4545
// TODO: Replace with proper {@link Dialect} rendering for limit/offset.
46+
// See https://github.com/spring-projects/spring-data-r2dbc/issues/55
4647
if (limit.isPresent()) {
4748

4849
LimitClause limitClause = dialect.limit();

src/test/java/org/springframework/data/r2dbc/function/StatementFactoryUnitTests.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,11 +27,11 @@
2727

2828
import org.springframework.data.r2dbc.dialect.PostgresDialect;
2929
import org.springframework.data.r2dbc.domain.SettableValue;
30+
import org.springframework.data.relational.core.dialect.RenderContextFactory;
3031
import org.springframework.data.relational.core.sql.Delete;
3132
import org.springframework.data.relational.core.sql.Insert;
3233
import org.springframework.data.relational.core.sql.Select;
3334
import org.springframework.data.relational.core.sql.Update;
34-
import org.springframework.data.relational.core.sql.render.NamingStrategies;
3535

3636
/**
3737
* Unit tests for {@link StatementFactory}.
@@ -40,7 +40,10 @@
4040
*/
4141
public class StatementFactoryUnitTests {
4242

43-
DefaultStatementFactory statements = new DefaultStatementFactory(PostgresDialect.INSTANCE, NamingStrategies::asIs);
43+
// See https://github.com/spring-projects/spring-data-r2dbc/issues/55
44+
DefaultStatementFactory statements = new DefaultStatementFactory(PostgresDialect.INSTANCE,
45+
new RenderContextFactory(org.springframework.data.relational.core.dialect.PostgresDialect.INSTANCE)
46+
.createRenderContext());
4447

4548
Statement statementMock = mock(Statement.class);
4649

@@ -133,7 +136,7 @@ public void shouldToQuerySimpleInsert() {
133136
});
134137

135138
assertThat(insert.getSource()).isInstanceOf(Insert.class);
136-
assertThat(insert.toQuery()).isEqualTo("INSERT INTO foo (bar) VALUES($1)");
139+
assertThat(insert.toQuery()).isEqualTo("INSERT INTO foo (bar) VALUES ($1)");
137140

138141
insert.bind(statementMock);
139142
verify(statementMock).bind(0, "Foo");

0 commit comments

Comments
 (0)