Skip to content

Commit

Permalink
开启了 v1.1.1 版本,默认求总记录数 count(*) 时的 SQL 增加了 as 列
Browse files Browse the repository at this point in the history
  • Loading branch information
blinkfox committed Oct 14, 2019
1 parent 8c51d15 commit d3d4376
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.1.1 求分页 count 小调整 (2018-10-10)

- **修改**了默认求总记录数 `count(*)` 时的 SQL 为 `count(*) as count`,即增加了 `as` 列;

## v1.1.0 新增返回任意实体对象或集合 (2018-10-10)

- **新增****返回任意实体对象**或集合的功能,相比使用投影的方式更为简单和自然;
Expand Down
2 changes: 1 addition & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![logo](assets/images/logo.png)

# Fenix <small>1.1.0</small>
# Fenix <small>1.1.1</small>

> 为解决复杂动态 SQL 而生的 Spring Data JPA 扩展库
Expand Down
8 changes: 4 additions & 4 deletions docs/quick-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<dependency>
<groupId>com.blinkfox</groupId>
<artifactId>fenix-spring-boot-starter</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
</dependency>
```

### Gradle

```bash
compile 'com.blinkfox:fenix-spring-boot-starter:1.1.0'
compile 'com.blinkfox:fenix-spring-boot-starter:1.1.1'
```

### 激活 Fenix FactoryBean
Expand Down Expand Up @@ -90,14 +90,14 @@ fenix:
<dependency>
<groupId>com.blinkfox</groupId>
<artifactId>fenix</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
</dependency>
```

### Gradle

```bash
compile 'com.blinkfox:fenix:1.1.0'
compile 'com.blinkfox:fenix:1.1.1'
```

### 激活 Fenix FactoryBean
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.blinkfox</groupId>
<artifactId>fenix</artifactId>
<version>1.1.0</version>
<version>1.1.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>fenix</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class FenixConfigManager {
+ " | __)/ __ \\ / \\| \\ \\/ /\n"
+ " | \\\\ ___/| | \\ |> < \n"
+ " \\___ / \\___ >___| /__/__/\\_ \\\n"
+ " \\/ \\/ \\/ \\/\n";
+ " \\/ \\/ \\/ \\/ v1.1.1\n";

/**
* Fenix 配置信息实例.
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/blinkfox/fenix/jpa/FenixJpaQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
public class FenixJpaQuery extends AbstractJpaQuery {

/**
* 用来替换 'select ... from' 为 'select count(*) from ' 的正则表达式.
* 用来替换 'select ... from' 为 'select count(*) as count from ' 的正则表达式.
*/
private static final String REGX_SELECT_FROM = "((?i)select)([\\s\\S]*?)((?i)from)";

/**
* 用来替换 'select ... from' 为 'select count(*) from ' 的求 count(*) 的常量.
* 用来替换 'select ... from' 为 'select count(*) as count from ' 的求 count(*) 的常量.
*/
private static final String SELECT_COUNT = "select count(*) from ";
private static final String SELECT_COUNT = "select count(*) as count from ";

/**
* JPA 参数对象.
Expand Down Expand Up @@ -264,7 +264,7 @@ private Pageable buildPagableAndSortSql(Object[] values) {
@Override
protected Query doCreateCountQuery(Object[] values) {
// 如果计数查询的 SQL 不为空(区分 Java和 Xml 两者方式),就重新构建 SqlInfo 信息,
// 否则就替换查询字符串中的字段值为 'count(*)'.
// 否则就替换查询字符串中的字段值为 'count(*) as count'.
String countSql = this.getCountSql();

// 创建 Query,并循环设置命名绑定参数.
Expand Down

0 comments on commit d3d4376

Please sign in to comment.