use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testDateAdditionExpressionMetaData2.
@Test
public void testDateAdditionExpressionMetaData2() throws Exception {
String query = "SELECT entity_id,a_string FROM atable where ?+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 testStringConcatMetaData.
@Test
public void testStringConcatMetaData() throws Exception {
String query = "SELECT entity_id,a_string FROM atable where 2 || a_integer || ? like '2%'";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, "foo");
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(1, pmd.getParameterCount());
assertEquals(String.class.getName(), pmd.getParameterClassName(1));
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testRowValueConstructorBindParamMetaDataWithBindArgsAtDiffPlacesOnLHSRHS.
@Test
public void testRowValueConstructorBindParamMetaDataWithBindArgsAtDiffPlacesOnLHSRHS() throws Exception {
String query = "SELECT a_integer, x_integer FROM aTable WHERE (a_integer, ?) = (?, a_integer)";
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(Integer.class.getName(), pmd.getParameterClassName(2));
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testRowValueConstructorBindParamMetaData.
@Test
public void testRowValueConstructorBindParamMetaData() throws Exception {
String query = "SELECT a_integer, x_integer FROM aTable WHERE (a_integer, x_integer, a_string) = (?, ?, ?)";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(3, pmd.getParameterCount());
assertEquals(Integer.class.getName(), pmd.getParameterClassName(1));
assertEquals(Integer.class.getName(), pmd.getParameterClassName(2));
assertEquals(String.class.getName(), pmd.getParameterClassName(3));
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testDateSubstractExpressionMetaData3.
@Test
public void testDateSubstractExpressionMetaData3() throws Exception {
String query = "SELECT entity_id,a_string FROM atable where a_date-?=a_integer";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(1, pmd.getParameterCount());
// FIXME: Should really be Integer, but we currently don't know if we're
// comparing to a date or a number where this is being calculated
// (which would disambiguate it).
assertEquals(null, pmd.getParameterClassName(1));
}
Aggregations