Skip to content

Commit

Permalink
Merge pull request #75 from shzlw/0.12.2
Browse files Browse the repository at this point in the history
0.12.2
  • Loading branch information
shzlw authored May 31, 2020
2 parents 1129ebd + 50af352 commit 5b90d6a
Show file tree
Hide file tree
Showing 25 changed files with 185 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ FROM openjdk:8-jre-alpine

WORKDIR /app

COPY --from=builder /app/src/target/poli-0.12.1.jar /app/poli-0.12.1.jar
COPY --from=builder /app/src/target/poli-0.12.2.jar /app/poli-0.12.2.jar
COPY --from=builder /app/src/db/poli.db /app/db/poli.db
COPY --from=builder /app/src/build_release/start.sh /app/start.sh
COPY --from=builder /app/src/config/poli.docker.properties /app/config/poli.properties
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# **Poli(魄力)**

[![Version](https://img.shields.io/badge/Version-0.12.1-0065FF.svg)](#)
[![Version](https://img.shields.io/badge/Version-0.12.2-0065FF.svg)](#)
[![license: MIT](https://img.shields.io/badge/license-MIT-FF5630.svg)](https://opensource.org/licenses/MIT)
[![Download](https://img.shields.io/github/downloads/shzlw/poli/total.svg?color=6554C0)](https://github.com/shzlw/poli/releases)
[![Docker Pulls](https://img.shields.io/docker/pulls/zhonglu/poli.svg)](https://cloud.docker.com/u/zhonglu/repository/docker/zhonglu/poli)
Expand Down Expand Up @@ -56,13 +56,13 @@ Auto refresh, drill through, fullscreen, embeds, color themes + more features in
Windows/Linux

```sh
java -jar poli-0.12.1.jar
java -jar poli-0.12.2.jar
```

Docker

```sh
docker run -d -p 6688:6688 --name poli zhonglu/poli:0.12.1
docker run -d -p 6688:6688 --name poli zhonglu/poli:0.12.2
```

Check [installation guide](https://shzlw.github.io/poli/#/installation) for more details.
Expand Down
2 changes: 1 addition & 1 deletion build_release/start.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java -jar poli-0.12.1.jar --spring.config.name=application,poli
java -jar poli-0.12.2.jar --spring.config.name=application,poli
2 changes: 1 addition & 1 deletion build_release/start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
set -e

java -jar poli-0.12.1.jar --spring.config.name=application,poli
java -jar poli-0.12.2.jar --spring.config.name=application,poli
7 changes: 7 additions & 0 deletions docs/change-logs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Logs

## v0.12.2

### Bug Fixes
- Add default value option for multi series charts (bar, line and area).
- Fix the issue that table column is not sorted correctly if the data type is number.
- Fix the query editor input lagging.

## v0.12.1

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
1. Pull and run the Poli image.

```bash
docker run -d -p 6688:6688 --name poli zhonglu/poli:0.12.1
docker run -d -p 6688:6688 --name poli zhonglu/poli:0.12.2
```
2. Add JDBC drivers.

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.shzlw.poli</groupId>
<artifactId>poli</artifactId>
<packaging>jar</packaging>
<version>0.12.1</version>
<version>0.12.2</version>
<name>Poli</name>
<description>The SQL BI tool</description>

Expand Down
50 changes: 44 additions & 6 deletions src/main/java/com/shzlw/poli/service/JdbcQueryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public QueryResult extractData(ResultSet rs) {
if (Constants.CONTENT_TYPE_CSV.equals(contentType)) {
data = resultSetToCsvString(rs, columnNames, maxQueryResult);
} else {
data = resultSetToJsonString(rs, columnNames, maxQueryResult);
data = resultSetToJsonString(rs, metadata, maxQueryResult);
}
return QueryResult.ofData(data, columns);
} catch (Exception e) {
Expand Down Expand Up @@ -167,7 +167,7 @@ public QueryResult extractData(ResultSet rs) {
ResultSetMetaData metadata = rs.getMetaData();
String[] columnNames = getColumnNames(metadata);
List<Column> columns = getColumnList(metadata);
String data = resultSetToJsonString(rs, columnNames, maxQueryResult);
String data = resultSetToJsonString(rs, metadata, maxQueryResult);
return QueryResult.ofData(data, columns);
} catch (Exception e) {
String error = CommonUtils.getSimpleError(e);
Expand Down Expand Up @@ -247,7 +247,7 @@ private List<Column> getColumnList(ResultSetMetaData metadata) throws SQLExcepti
int columnCount = metadata.getColumnCount();
List<Column> columns = new ArrayList<>();
for (int i = 1; i <= columnCount; i++) {
int columnType = metadata.getColumnType(i);
int columnType = metadata.getColumnType(i);;
String dbType = metadata.getColumnTypeName(i);
int length = metadata.getColumnDisplaySize(i);
// Use column label to fetch the column alias instead of using column name.
Expand All @@ -258,15 +258,52 @@ private List<Column> getColumnList(ResultSetMetaData metadata) throws SQLExcepti
return columns;
}

private String resultSetToJsonString(ResultSet rs, String[] columnNames, int maxQueryResult) throws SQLException {
int columnCount = columnNames.length - 1;
private String resultSetToJsonString(ResultSet rs, ResultSetMetaData metadata, int maxQueryResult) throws SQLException {
int columnCount = metadata.getColumnCount();
ObjectMapper mapper = new ObjectMapper();
ArrayNode array = mapper.createArrayNode();
int rowCount = 0;
while (rs.next()) {
ObjectNode node = mapper.createObjectNode();
for (int i = 1; i <= columnCount; i++) {
node.put(columnNames[i], rs.getString(i));
String columnLabel = metadata.getColumnLabel(i);
int columnType = metadata.getColumnType(i);
switch (columnType) {
case java.sql.Types.VARCHAR:
case java.sql.Types.CHAR:
case java.sql.Types.LONGVARCHAR:
node.put(columnLabel, rs.getString(i));
break;
case java.sql.Types.TINYINT:
case java.sql.Types.SMALLINT:
case java.sql.Types.INTEGER:
node.put(columnLabel, rs.getInt(i));
break;
case java.sql.Types.NUMERIC:
case java.sql.Types.DECIMAL:
node.put(columnLabel, rs.getBigDecimal(i));
break;
case java.sql.Types.DOUBLE:
case java.sql.Types.FLOAT:
case java.sql.Types.REAL:
node.put(columnLabel, rs.getDouble(i));
break;
case java.sql.Types.BOOLEAN:
case java.sql.Types.BIT:
node.put(columnLabel, rs.getBoolean(i));
break;
case java.sql.Types.BIGINT:
node.put(columnLabel, rs.getLong(i));
break;
case java.sql.Types.NVARCHAR:
case java.sql.Types.NCHAR:
node.put(columnLabel, rs.getNString(i));
break;
default:
// Unhandled types
node.put(columnLabel, rs.getString(i));
break;
}
}
array.add(node);
rowCount++;
Expand All @@ -277,6 +314,7 @@ private String resultSetToJsonString(ResultSet rs, String[] columnNames, int max
return array.toString();
}


private String resultSetToCsvString(ResultSet rs, String[] columnNames, int maxQueryResult) throws SQLException {
int columnCount = columnNames.length - 1;
StringBuilder sb = new StringBuilder();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/shzlw/poli/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public final class Constants {

private Constants() {}

public static final String CURRENT_VERSION = "0.12.1";
public static final String CURRENT_VERSION = "0.12.2";

public static final String SUCCESS = "success";
public static final String GOOD = "";
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
VERSION=0.12.1
VERSION=0.12.2

echo $VERSION
16 changes: 12 additions & 4 deletions web-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "poli-web-app",
"version": "0.12.1",
"version": "0.12.2",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.28",
Expand Down
Loading

0 comments on commit 5b90d6a

Please sign in to comment.