Skip to content

Commit

Permalink
return proper driver versions
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn committed Dec 19, 2023
1 parent 5b978c0 commit bf024c0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

import static com.aerospike.jdbc.util.AerospikeUtils.getCatalogIndexes;
import static com.aerospike.jdbc.util.AerospikeUtils.getClusterInfo;
import static com.aerospike.jdbc.util.Constants.DRIVER_MAJOR_VERSION;
import static com.aerospike.jdbc.util.Constants.DRIVER_MINOR_VERSION;
import static com.aerospike.jdbc.util.Constants.DRIVER_VERSION;
import static com.aerospike.jdbc.util.Constants.JDBC_MAJOR_VERSION;
import static com.aerospike.jdbc.util.Constants.JDBC_MINOR_VERSION;
import static com.aerospike.jdbc.util.Constants.PRIMARY_KEY_COLUMN_NAME;
Expand Down Expand Up @@ -157,17 +160,17 @@ public String getDriverName() {

@Override
public String getDriverVersion() {
return "NA";
return DRIVER_VERSION;
}

@Override
public int getDriverMajorVersion() {
return 1;
return DRIVER_MAJOR_VERSION;
}

@Override
public int getDriverMinorVersion() {
return 0;
return DRIVER_MINOR_VERSION;
}

@Override
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/aerospike/jdbc/AerospikeDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.util.Properties;
import java.util.logging.Logger;

import static com.aerospike.jdbc.util.Constants.DRIVER_MAJOR_VERSION;
import static com.aerospike.jdbc.util.Constants.DRIVER_MINOR_VERSION;
import static java.util.stream.Collectors.toList;

public class AerospikeDriver implements Driver {
Expand Down Expand Up @@ -55,11 +57,11 @@ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
}

public int getMajorVersion() {
return 1;
return DRIVER_MAJOR_VERSION;
}

public int getMinorVersion() {
return 0;
return DRIVER_MINOR_VERSION;
}

public boolean jdbcCompliant() {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/aerospike/jdbc/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ public final class Constants {

public static final String UNSUPPORTED_QUERY_TYPE_MESSAGE = "Unsupported query type";

// Driver version
public static final String DRIVER_VERSION = "1.7.5";
public static final int DRIVER_MAJOR_VERSION = 1;
public static final int DRIVER_MINOR_VERSION = 7;

// JDBC specification
public static final String JDBC_VERSION = "4.2";
public static final int JDBC_MAJOR_VERSION = JDBC_VERSION.charAt(0) - '0';
Expand Down
15 changes: 7 additions & 8 deletions src/test/java/com/aerospike/jdbc/DatabaseMetadataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void tearDown() throws SQLException {
@Test
public void testGetTables() throws SQLException {
DatabaseMetaData databaseMetaData = connection.getMetaData();
ResultSet tables = databaseMetaData.getTables(namespace, namespace, tableName, null);
ResultSet tables = databaseMetaData.getTables(namespace, "", tableName, null);

if (tables.next()) {
assertEquals(tables.getString("TABLE_NAME"), tableName);
Expand All @@ -66,13 +66,12 @@ public void testGetTables() throws SQLException {
public void testGetSchemas() throws SQLException {
ResultSet schemas = connection.getMetaData().getSchemas();

if (schemas.next()) {
String schemaName = schemas.getString(1);
String catalogName = schemas.getString(2);
assertEquals(schemas.getString("TABLE_SCHEM"), schemaName);
assertEquals(schemas.getString("TABLE_CATALOG"), catalogName);
assertFalse(schemas.next());
}
assertTrue(schemas.next());
String schemaName = schemas.getString(1);
String catalogName = schemas.getString(2);
assertEquals(schemas.getString("TABLE_SCHEM"), schemaName);
assertEquals(schemas.getString("TABLE_CATALOG"), catalogName);
assertFalse(schemas.next());
TestUtil.closeQuietly(schemas);
}

Expand Down

0 comments on commit bf024c0

Please sign in to comment.