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

Upgraded liquibase to 3.6.3. Updated to close Statement and ResultSet Removed unnecessary throws. Bumped java version to Java 7. #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-snowflake</artifactId>
<version>1.0</version>
<version>1.1</version>

<name>Liquibase Snowflake Database Integration</name>
<description>Liquibase extension for Snowflake database</description>
Expand Down Expand Up @@ -44,8 +44,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
<optimize>true</optimize>
<debug>true</debug>
<encoding>UTF-8</encoding>
Expand All @@ -72,7 +72,7 @@
</build>

<properties>
<liquibase.version>3.5.3</liquibase.version>
<liquibase.version>3.6.3</liquibase.version>
<junit.version>4.11</junit.version>
<maven.compiler.version>3.1</maven.compiler.version>
<mockito.core.version>2.7.22</mockito.core.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
import liquibase.database.DatabaseConnection;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.DatabaseException;
import liquibase.logging.LogFactory;
import liquibase.logging.LogService;
import liquibase.logging.Logger;
import liquibase.structure.DatabaseObject;

import java.math.BigInteger;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class SnowflakeDatabase extends AbstractJdbcDatabase {

private Logger log = new LogFactory().getLog();
public static final String PRODUCT_NAME = "Snowflake";
private Set<String> systemTables = new HashSet<String>();
private Set<String> systemViews = new HashSet<String>();
private Set<String> reservedWords = new HashSet<String>();
private static final String PRODUCT_NAME = "Snowflake";

private Logger log = LogService.getLog(getClass());
private Set<String> systemTables = new HashSet<>();
private Set<String> systemViews = new HashSet<>();

public SnowflakeDatabase() {
super.setCurrentDateTimeFunction("current_timestamp::timestamp_ntz");
Expand Down Expand Up @@ -171,24 +171,14 @@ public boolean supportsRestrictForeignKeys() {
return true;
}

@Override
public void addReservedWords(Collection<String> words) {
reservedWords.addAll(words);
}

@Override
public boolean isReservedWord(String tableName) {
return reservedWords.contains(tableName.toUpperCase());
}

@Override
protected String getConnectionSchemaName() {
DatabaseConnection connection = getConnection();
if (connection == null) {
return null;
}
try {
ResultSet resultSet = ((JdbcConnection) connection).createStatement().executeQuery("SELECT CURRENT_SCHEMA()");
try (Statement statement = ((JdbcConnection) connection).createStatement();
ResultSet resultSet = statement.executeQuery("SELECT CURRENT_SCHEMA()")) {
resultSet.next();
String schema = resultSet.getString(1);
return schema;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package liquibase.ext.snowflake.datatype;

import liquibase.change.core.LoadDataChange;
import liquibase.database.Database;
import liquibase.datatype.DataTypeInfo;
import liquibase.datatype.DatabaseDataType;
import liquibase.datatype.LiquibaseDataType;
import liquibase.ext.snowflake.database.SnowflakeDatabase;

@DataTypeInfo(name="timestamp_ntz", aliases = { "java.sql.Types.DATETIME", "datetime"}, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DATABASE)
@DataTypeInfo(name = "timestamp_ntz", aliases = {"java.sql.Types.DATETIME", "datetime"}, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DATABASE)
public class TimestampNTZType extends LiquibaseDataType {

@Override
Expand All @@ -24,11 +25,14 @@ public void finishInitialization(String originalDefinition) {
super.finishInitialization(originalDefinition);
}

@Override
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
return LoadDataChange.LOAD_DATA_TYPE.DATE;
}

@Override
public boolean supports(Database database) {
if (database instanceof SnowflakeDatabase)
return true;
return false;
return database instanceof SnowflakeDatabase;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class SnowflakeDatabaseTest {

SnowflakeDatabase database;
private SnowflakeDatabase database;

@Before
public void setup() {
Expand Down Expand Up @@ -173,7 +173,7 @@ public void defaultCatalogNameIsUpperCase() throws Exception {
}

@Test
public void defaultCatalogNameIsNullWhenConnectionIsNull() throws Exception {
public void defaultCatalogNameIsNullWhenConnectionIsNull() {
assertNull(database.getDefaultCatalogName());
}

Expand All @@ -193,7 +193,7 @@ public void defaultSchemaNameIsUpperCase() throws Exception {
}

@Test
public void defaultSchemaNameIsNullWhenConnectionIsNull() throws Exception {
public void defaultSchemaNameIsNullWhenConnectionIsNull() {
assertNull(database.getDefaultSchemaName());
}

Expand Down