Skip to content

Update dependencies, code polishing #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
# Change Log

## Release 1.1.1 (Unreleased)
This log will detail notable changes to MyBatis Dynamic SQL. Full details are available on the GitHub milestone pages.

## Release 1.1.1

GitHub milestone: [https://github.com/mybatis/mybatis-dynamic-sql/issues?q=milestone%3A1.1.1+](https://github.com/mybatis/mybatis-dynamic-sql/issues?q=milestone%3A1.1.1+)

### Added

- Limit and offset support in the select statement
- Utilities for Spring Batch
- All conditions now support conditional rendering with lambdas
- Select * support
- Union all support

### Bugs Fixed

- Fixed self joins


## Release 1.1.0

GitHub milestone: [https://github.com/mybatis/mybatis-dynamic-sql/issues?q=milestone%3A1.1.0+](https://github.com/mybatis/mybatis-dynamic-sql/issues?q=milestone%3A1.1.0+)

### Added

- Support for optional conditions
- Support for column comparison conditions
- Support for sub-queries in the update statement
- Support for expressions and constants in the select statement
- Support for function in the update statement

### Bugs Fixed

- Support group by after where

## Initial Release - December 17, 2017
17 changes: 9 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<junit.jupiter.version>5.4.0</junit.jupiter.version>
<junit.platform.version>1.4.0</junit.platform.version>
<junit.jupiter.version>5.4.1</junit.jupiter.version>
<junit.platform.version>1.4.1</junit.platform.version>
<spring.batch.version>4.1.2.RELEASE</spring.batch.version>
<clirr.comparisonVersion>1.1.0</clirr.comparisonVersion>
<module.name>org.mybatis.dynamic.sql</module.name>
</properties>
Expand Down Expand Up @@ -121,19 +122,19 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.12.1</version>
<version>3.12.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.0</version>
<version>3.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -145,19 +146,19 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.1.5.RELEASE</version>
<version>5.1.6.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>4.1.1.RELEASE</version>
<version>${spring.batch.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<version>4.1.1.RELEASE</version>
<version>${spring.batch.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ public String getFormattedJdbcPlaceholder(String prefix, String parameterName) {
return getFormattedJdbcPlaceholder(Optional.empty(), prefix, parameterName);
}

public abstract String getFormattedJdbcPlaceholder(Optional<BindableColumn<?>> column, String prefix, String parameterName);
public abstract String getFormattedJdbcPlaceholder(Optional<BindableColumn<?>> column, String prefix,
String parameterName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ private String orderByPhrase(SortSpecification column) {
}

private String renderLimit(Map<String, Object> parameters, Long limit) {
String placeholder = renderingStrategy.getFormattedJdbcPlaceholder(RenderingStrategy.DEFAULT_PARAMETER_PREFIX, LIMIT_PARAMETER);
String placeholder = renderingStrategy.getFormattedJdbcPlaceholder(RenderingStrategy.DEFAULT_PARAMETER_PREFIX,
LIMIT_PARAMETER);
parameters.put(LIMIT_PARAMETER, limit);
return "limit " + placeholder; //$NON-NLS-1$
}

private String renderOffset(Map<String, Object> parameters, Long offset) {
String placeholder = renderingStrategy.getFormattedJdbcPlaceholder(RenderingStrategy.DEFAULT_PARAMETER_PREFIX, OFFSET_PARAMETER);
String placeholder = renderingStrategy.getFormattedJdbcPlaceholder(RenderingStrategy.DEFAULT_PARAMETER_PREFIX,
OFFSET_PARAMETER);
parameters.put(OFFSET_PARAMETER, offset);
return "offset " + placeholder; //$NON-NLS-1$
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.batch.test.context.SpringBatchTest;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -61,10 +62,14 @@ public void testThatRowsAreTransformedToUpperCase() throws Exception {
private int numberOfRowsProcessed(JobExecution jobExecution) {
return jobExecution.getStepExecutions().stream()
.map(StepExecution::getExecutionContext)
.mapToInt(ec -> ec.getInt("row_count"))
.mapToInt(this::getRowCount)
.sum();
}

private int getRowCount(ExecutionContext executionContext) {
return executionContext.getInt("row_count", 0);
}

private long upperCaseRowCount() throws Exception {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PersonMapper personMapper = sqlSession.getMapper(PersonMapper.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.batch.test.context.SpringBatchTest;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -62,17 +63,25 @@ public void testThatRowsAreTransformedToUpperCase() throws Exception {
private int numberOfRowsProcessed(JobExecution jobExecution) {
return jobExecution.getStepExecutions().stream()
.map(StepExecution::getExecutionContext)
.mapToInt(ec -> ec.getInt("row_count"))
.mapToInt(this::getRowCount)
.sum();
}

private int getRowCount(ExecutionContext executionContext) {
return executionContext.getInt("row_count", 0);
}

private int numberOfChunks(JobExecution jobExecution) {
return jobExecution.getStepExecutions().stream()
.map(StepExecution::getExecutionContext)
.mapToInt(ec -> ec.getInt("chunk_count"))
.mapToInt(this::getChunkCount)
.sum();
}

private int getChunkCount(ExecutionContext executionContext) {
return executionContext.getInt("chunk_count", 0);
}

private long upperCaseRowCount() throws Exception {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PersonMapper personMapper = sqlSession.getMapper(PersonMapper.class);
Expand Down