use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testDateAdditionExpressionMetaData1.
@Test
public void testDateAdditionExpressionMetaData1() throws Exception {
String query = "SELECT entity_id,a_string FROM atable where 1+a_date+?>a_date";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(1, pmd.getParameterCount());
assertEquals(BigDecimal.class.getName(), pmd.getParameterClassName(1));
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testRowValueConstructorBindParamMetaDataWithBindArgsOnLHSAndLiteralExprOnRHS.
// @Test broken currently, as we'll end up with null = 7 which is never true
public void testRowValueConstructorBindParamMetaDataWithBindArgsOnLHSAndLiteralExprOnRHS() throws Exception {
String query = "SELECT a_integer, x_integer FROM aTable WHERE (?, ?) = 7";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(2, pmd.getParameterCount());
assertEquals(Integer.class.getName(), pmd.getParameterClassName(1));
assertEquals(null, pmd.getParameterClassName(2));
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testLimitParameterMetaData.
@Test
public void testLimitParameterMetaData() throws Exception {
String query = "SELECT a_string, b_string FROM atable WHERE organization_id=? and a_string = 'foo' LIMIT ?";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(2, pmd.getParameterCount());
assertEquals(String.class.getName(), pmd.getParameterClassName(1));
assertEquals(Integer.class.getName(), pmd.getParameterClassName(2));
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testInListParameterMetaData4.
@Test
public void testInListParameterMetaData4() throws Exception {
String query = "SELECT a_string, b_string FROM atable WHERE ? IN (?, ?)";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(3, pmd.getParameterCount());
assertEquals(null, pmd.getParameterClassName(1));
assertEquals(null, pmd.getParameterClassName(2));
assertEquals(null, pmd.getParameterClassName(3));
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testCaseMetaData.
@Test
public void testCaseMetaData() throws Exception {
String query1 = "SELECT a_string, b_string FROM atable WHERE case when a_integer = 1 then ? when a_integer > 2 then 2 end > 3";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query1);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(1, pmd.getParameterCount());
assertEquals(BigDecimal.class.getName(), pmd.getParameterClassName(1));
assertEquals(ParameterMetaData.parameterNullable, pmd.isNullable(1));
String query2 = "SELECT a_string, b_string FROM atable WHERE case when a_integer = 1 then 1 when a_integer > 2 then 2 end > ?";
PreparedStatement statement2 = conn.prepareStatement(query2);
ParameterMetaData pmd2 = statement2.getParameterMetaData();
assertEquals(1, pmd2.getParameterCount());
assertEquals(Integer.class.getName(), pmd2.getParameterClassName(1));
assertEquals(ParameterMetaData.parameterNullable, pmd2.isNullable(1));
}
Aggregations