Skip to content
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

dbeaver/pro#3793 Back to roots (11) #14

Merged
merged 1 commit into from
Dec 9, 2024
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
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 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,11 +221,11 @@
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)
public byte[] getBytes(String columnLabel) throws SQLException {
Object object = getObject(columnLabel);
return object == null ? null : object.toString().getBytes();
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 @@ -132,16 +132,17 @@
return resultSets;
}
} 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 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
Loading