Skip to content

Commit

Permalink
dbeaver/pro#3793 Back to roots (11)
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-rider committed Dec 8, 2024
1 parent c44b380 commit 2514b6b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 23 deletions.
2 changes: 1 addition & 1 deletion com.dbeaver.jdbc.driver.libsql/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Name: DBeaver LibSQL JDBC Driver
Bundle-SymbolicName: com.dbeaver.jdbc.driver.libsql
Bundle-Version: 1.0.3.qualifier
Bundle-Release-Date: 20230522
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-RequiredExecutionEnvironment: JavaSE-11
Export-Package: com.dbeaver.jdbc.driver.libsql,
com.dbeaver.jdbc.driver.libsql.client
Require-Bundle: com.dbeaver.jdbc.api,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public double getDouble(int columnIndex) throws SQLException {
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
Object object = getObject(columnIndex);
return object == null ? null :
object instanceof BigDecimal bd ? bd :
object instanceof Long str ? BigDecimal.valueOf(str) : BigDecimal.valueOf(CommonUtils.toDouble(object));
object instanceof BigDecimal ? (BigDecimal) object :
object instanceof Long ? BigDecimal.valueOf((Long) object) : BigDecimal.valueOf(CommonUtils.toDouble(object));
}

@Override
Expand Down Expand Up @@ -221,8 +221,8 @@ public double getDouble(String columnLabel) throws SQLException {
public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
Object object = getObject(columnLabel);
return object == null ? null :
object instanceof BigDecimal bd ? bd :
object instanceof Long str ? BigDecimal.valueOf(str) : BigDecimal.valueOf(CommonUtils.toDouble(object));
object instanceof BigDecimal ? (BigDecimal) object :
object instanceof Long ? BigDecimal.valueOf((Long) object) : BigDecimal.valueOf(CommonUtils.toDouble(object));
}

@Override

Check warning on line 228 in com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSet.java

View workflow job for this annotation

GitHub Actions / Check / Lint

[checkstyle] reported by reviewdog 🐶 All overloaded methods should be placed next to each other. Previous overloaded method located at line '141'. Raw Output: /github/workspace/./com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlResultSet.java:228:5: warning: All overloaded methods should be placed next to each other. Previous overloaded method located at line '141'. (com.puppycrawl.tools.checkstyle.checks.coding.OverloadMethodsDeclarationOrderCheck)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,30 @@ public String getTableName(int column) throws SQLException {

@Override
public int getColumnType(int column) throws SQLException {
return switch (getDataTypeFromData(column)) {
case BOOLEAN -> Types.BOOLEAN;
case NUMBER -> Types.NUMERIC;
case STRING -> Types.VARCHAR;
default -> Types.OTHER;
};
switch (getDataTypeFromData(column)) {
case BOOLEAN:
return Types.BOOLEAN;
case NUMBER:
return Types.NUMERIC;
case STRING:
return Types.VARCHAR;
default:
return Types.OTHER;
}
}

@Override
public String getColumnTypeName(int column) throws SQLException {
return switch (getDataTypeFromData(column)) {
case BOOLEAN -> "BOOLEAN";
case NUMBER -> "NUMERIC";
case STRING -> "VARCHAR";
default -> "UNKNOWN";
};
switch (getDataTypeFromData(column)) {
case BOOLEAN:
return "BOOLEAN";
case NUMBER:
return "NUMERIC";
case STRING:
return "VARCHAR";
default:
return "UNKNOWN";
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,16 @@ public LibSqlExecutionResult[] executeBatch(
}
} catch (Exception e) {
switch (httpResponse.statusCode()) {

Check warning on line 135 in com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java

View workflow job for this annotation

GitHub Actions / Check / Lint

[checkstyle] reported by reviewdog 🐶 switch without "default" clause. Raw Output: /github/workspace/./com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java:135:17: warning: switch without "default" clause. (com.puppycrawl.tools.checkstyle.checks.coding.MissingSwitchDefaultCheck)
case HttpURLConnection.HTTP_UNAUTHORIZED ->
case HttpURLConnection.HTTP_UNAUTHORIZED:
throw new SQLException("Authentication required", e);
case HttpURLConnection.HTTP_FORBIDDEN ->
case HttpURLConnection.HTTP_FORBIDDEN:
throw new SQLException("Access denied", e);
}
throw e;
}
} catch (Exception e) {
if (e instanceof SQLException sqle) {
if (e instanceof SQLException) {
SQLException sqle = (SQLException) e;
throw sqle;
}
throw new SQLException(e);
Expand Down Expand Up @@ -217,11 +218,14 @@ private boolean isIndexedParams(Map<Object, Object> parameter) {
private static void serializeParameterValue(Object value, JsonWriter jsonWriter) throws IOException {
if (value == null) {
jsonWriter.nullValue();
} else if (value instanceof Number nValue) {
} else if (value instanceof Number) {
Number nValue = (Number) value;

Check warning on line 222 in com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java

View workflow job for this annotation

GitHub Actions / Check / Lint

[checkstyle] reported by reviewdog 🐶 Local variable name 'nValue' must match pattern '^[a-z]([a-z0-9][a-zA-Z0-9]*)?$'. Raw Output: /github/workspace/./com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java:222:20: warning: Local variable name 'nValue' must match pattern '^[a-z]([a-z0-9][a-zA-Z0-9]*)?$'. (com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck)
jsonWriter.value(nValue);
} else if (value instanceof Boolean bValue) {
} else if (value instanceof Boolean) {
Boolean bValue = (Boolean) value;

Check warning on line 225 in com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java

View workflow job for this annotation

GitHub Actions / Check / Lint

[checkstyle] reported by reviewdog 🐶 Local variable name 'bValue' must match pattern '^[a-z]([a-z0-9][a-zA-Z0-9]*)?$'. Raw Output: /github/workspace/./com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java:225:21: warning: Local variable name 'bValue' must match pattern '^[a-z]([a-z0-9][a-zA-Z0-9]*)?$'. (com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck)
jsonWriter.value(bValue);
} else if (value instanceof String strValue) {
} else if (value instanceof String) {
String strValue = (String) value;
jsonWriter.value(strValue);
} else {
jsonWriter.value(value.toString());
Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>

<plugins>
<!-- Use minimum supported Java -->
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useProjectSettings>false</useProjectSettings>
<source>${java.version.min}</source>
<target>${java.version.min}</target>
<compilerVersion>${java.version.min}</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down

0 comments on commit 2514b6b

Please sign in to comment.