Skip to content

Commit

Permalink
#10 Standard columns support added (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-rider authored Nov 15, 2024
1 parent e57453e commit 1421e06
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 6 deletions.
29 changes: 28 additions & 1 deletion com.dbeaver.jdbc.driver.libsql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,39 @@
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
<outputDirectory>${project.build.directory}/dist</outputDirectory>
<includeScope>runtime</includeScope>
<stripClassifier>com.dbeaver.jdbc.driver.libsql</stripClassifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>assemble-driver-dist</id>
<phase>package</phase>
<configuration>
<outputDirectory>${project.build.directory}/dist</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</configuration>
<goals>
<goal>copy-resources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,31 @@ public ResultSet getColumns(String catalog, String schemaPattern, String tableNa
return executeQuery(
"WITH all_tables AS (SELECT name AS tn FROM sqlite_master WHERE type = 'table'" +
(tableName == null ? "" : " and name=" + LibSqlUtils.quote(tableName)) + ") \n" +
"SELECT NULL as TABLE_CAT, NULL AS TABLE_SCHEM, at.tn as TABLE_NAME,\n" +
"pti.name as COLUMN_NAME," + Types.VARCHAR + " AS DATA_TYPE, pti.type AS TYPE_NAME, 0 AS COLUMN_SIZE," +
"NULL AS REMARKS,pti.cid AS ORDINAL_POSITION " +
"SELECT " +
"NULL as TABLE_CAT, " +
"NULL AS TABLE_SCHEM, " +
"at.tn as TABLE_NAME,\n" +
"pti.name as COLUMN_NAME," +
Types.VARCHAR + " AS DATA_TYPE," +
"pti.type AS TYPE_NAME," +
"0 AS COLUMN_SIZE," +
"0 as COLUMN_SIZE," +
"0 as BUFFER_LENGTH," +
"0 as DECIMAL_DIGITS,\n" +
columnNullable + " as NULLABLE," +
"NULL as REMARKS," +
"NULL as COLUMN_DEF," +
"0 as SQL_DATA_TYPE," +
"0 as SQL_DATETIME_SUB," +
"0 as CHAR_OCTET_LENGTH," +
"pti.cid as ORDINAL_POSITION," +
"'' as IS_NULLABLE," +
"NULL as SCOPE_CATALOG," +
"NULL as SCOPE_SCHEMA," +
"NULL as SCOPE_TABLE," +
"NULL as SOURCE_DATA_TYPE," +
"'' as IS_AUTOINCREMENT," +
"'' as IS_GENERATEDCOLUMN\n" +
"FROM all_tables at INNER JOIN pragma_table_info(at.tn) pti\n" +
"ORDER BY TABLE_NAME");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.sql.SQLException;
import java.sql.Types;
import java.util.List;

public class LibSqlResultSetMetaData extends AbstractJdbcResultSetMetaData<LibSqlStatement> {

Expand Down Expand Up @@ -102,7 +103,11 @@ public String getColumnLabel(int column) throws SQLException {

@Override
public String getColumnName(int column) throws SQLException {
return resultSet.getResult().getColumns().get(column - 1);
List<String> columns = resultSet.getResult().getColumns();
if (column < 1 || column > columns.size()) {
throw new SQLException("Column index out of bounds: " + column + "/" + columns.size());
}
return columns.get(column - 1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public LibSqlExecutionResult[] executeBatch(
.header("Content-Type", "application/json")
.header("User-Agent", userAgent)
.POST(HttpRequest.BodyPublishers.ofString(requestBuffer.toString()));
if (authToken != null) {
if (!CommonUtils.isEmpty(authToken)) {
builder.header("Authorization", "Bearer " + authToken);
}

Expand Down

0 comments on commit 1421e06

Please sign in to comment.