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

SNOW-1844765 Make createArrayOf case-insensitive #2010

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ public String getClientInfo(String name) throws SQLException {
@Override
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
logger.trace("Array createArrayOf(String typeName, Object[] " + "elements)", false);
return new SfSqlArray(JDBCType.valueOf(typeName).getVendorTypeNumber(), elements);
return new SfSqlArray(JDBCType.valueOf(typeName.toUpperCase()).getVendorTypeNumber(), elements);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
import static net.snowflake.client.jdbc.DefaultSFConnectionHandler.mergeProperties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.sql.Array;
import java.sql.JDBCType;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Properties;
import net.snowflake.client.core.SFBaseSession;
import org.junit.jupiter.api.Test;

/** Created by hyu on 2/2/18. */
Expand Down Expand Up @@ -198,4 +205,19 @@ public void testMergeProperties() {
assertThat(result.get("PROP1"), is("value1|value2"));
assertThat(result.get("PROP2"), is("carrot^"));
}

@Test
public void testCreateArrayOfIsCaseInsensitive() throws SQLException {
SFConnectionHandler mockConnectionHandler = mock(SFConnectionHandler.class);
SFBaseSession sfBaseSession = mock(SFBaseSession.class);
when(mockConnectionHandler.getSFSession()).thenReturn(sfBaseSession);
when(sfBaseSession.checkProperties()).thenReturn(new ArrayList<>());
try (SnowflakeConnectionV1 connectionV1 = new SnowflakeConnectionV1(mockConnectionHandler)) {
sfc-gh-mkubik marked this conversation as resolved.
Show resolved Hide resolved
Array arrayLowerCase = connectionV1.createArrayOf("integer", new Integer[] {1, 2, 3});
Array arrayUpperCase = connectionV1.createArrayOf("VARCHAR", new String[] {"one", "two"});

assertThat(arrayLowerCase.getBaseTypeName(), is(JDBCType.INTEGER.getName()));
assertThat(arrayUpperCase.getBaseTypeName(), is(JDBCType.VARCHAR.getName()));
}
}
}
Loading