]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge of (#10032) to Vaadin 7. 07/607/1
authorAnna Koskinen <anna@vaadin.com>
Wed, 9 Jan 2013 13:49:20 +0000 (15:49 +0200)
committerAnna Koskinen <anna@vaadin.com>
Wed, 9 Jan 2013 13:49:20 +0000 (15:49 +0200)
SQLContainer and DB2 not handling empty result set metadata correctly.

Change-Id: I20ad1e3d528f92826e3f9049403c6a953a6a07c8

server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
server/tests/src/com/vaadin/data/util/sqlcontainer/TicketTests.java

index 742e68738a33671e4512aecb8ed41478c1ebdcd6..f7f3e73a7f7979e453d3405fdd467194adec0312 100644 (file)
@@ -1149,8 +1149,8 @@ public class SQLContainer implements Container, Container.Filterable,
         try {
             delegate.beginTransaction();
             rs = delegate.getResults(0, 1);
-            boolean resultExists = rs.next();
             rsmd = rs.getMetaData();
+            boolean resultExists = rs.next();
             Class<?> type = null;
             for (int i = 1; i <= rsmd.getColumnCount(); i++) {
                 if (!isColumnIdentifierValid(rsmd.getColumnLabel(i))) {
index 6e95aff0277ee1d4565f803dbd64804cb1918fb1..8e8c83d234c5181e5b9fa9442bb1af6e211548b9 100644 (file)
@@ -183,4 +183,16 @@ public class TicketTests {
 
         Assert.assertEquals(name, name3);
     }
+
+    @Test
+    public void ticket10032_empty_set_metadata_correctly_handled()
+            throws SQLException {
+        // If problem exists will break when method getPropertyIds()
+        // is called in constructor SQLContainer(QueryDelegate delegate).
+        SQLContainer container = new SQLContainer(new FreeformQuery(
+                "SELECT * FROM people WHERE name='does_not_exist'",
+                Arrays.asList("ID"), connectionPool));
+        Assert.assertTrue("Got items while expected empty set",
+                container.size() == 0);
+    }
 }