From cafadd5b0f3350208265176f27b4e6b7693044fb Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 4 Jan 2013 13:49:15 +0100 Subject: [PATCH] Split up subselect integration tests by type --- .../jooq/test/_/testcases/SelectTests.java | 116 +++++++++--------- .../src/org/jooq/test/jOOQAbstractTest.java | 20 +++ 2 files changed, 80 insertions(+), 56 deletions(-) diff --git a/jOOQ-test/src/org/jooq/test/_/testcases/SelectTests.java b/jOOQ-test/src/org/jooq/test/_/testcases/SelectTests.java index 57791a14b3..54cdba253f 100644 --- a/jOOQ-test/src/org/jooq/test/_/testcases/SelectTests.java +++ b/jOOQ-test/src/org/jooq/test/_/testcases/SelectTests.java @@ -167,62 +167,6 @@ extends BaseTest nested = create().select(TBook_AUTHOR_ID(), count().as("books")) - .from(TBook()) - .groupBy(TBook_AUTHOR_ID()).asTable("nested"); - - Result records = create().select(nested.getFields()) - .from(nested) - .orderBy(nested.getField("books"), nested.getField(TBook_AUTHOR_ID())).fetch(); - - assertEquals(2, records.size()); - assertEquals(Integer.valueOf(1), records.getValue(0, nested.getField(TBook_AUTHOR_ID()))); - assertEquals(Integer.valueOf(2), records.getValue(0, nested.getField("books"))); - assertEquals(Integer.valueOf(2), records.getValue(1, nested.getField(TBook_AUTHOR_ID()))); - assertEquals(Integer.valueOf(2), records.getValue(1, nested.getField("books"))); - - Field books = create().select(count()) - .from(TBook()) - .where(TBook_AUTHOR_ID().equal(TAuthor_ID())).asField("books"); - - records = create().select(TAuthor_ID(), books) - .from(TAuthor()) - .orderBy(books, TAuthor_ID()).fetch(); - - assertEquals(2, records.size()); - assertEquals(Integer.valueOf(1), records.getValue(0, TAuthor_ID())); - assertEquals(Integer.valueOf(2), records.getValue(0, books)); - assertEquals(Integer.valueOf(2), records.getValue(1, TAuthor_ID())); - assertEquals(Integer.valueOf(2), records.getValue(1, books)); // --------------------------------------------------------------------- // [#493, #632] Testing filtering by a select's outcome @@ -250,6 +194,66 @@ extends BaseTest nested = create().select(TBook_AUTHOR_ID(), count().as("books")) + .from(TBook()) + .groupBy(TBook_AUTHOR_ID()).asTable("nested"); + + Result records = create().select(nested.getFields()) + .from(nested) + .orderBy(nested.getField("books"), nested.getField(TBook_AUTHOR_ID())).fetch(); + + assertEquals(2, records.size()); + assertEquals(Integer.valueOf(1), records.getValue(0, nested.getField(TBook_AUTHOR_ID()))); + assertEquals(Integer.valueOf(2), records.getValue(0, nested.getField("books"))); + assertEquals(Integer.valueOf(2), records.getValue(1, nested.getField(TBook_AUTHOR_ID()))); + assertEquals(Integer.valueOf(2), records.getValue(1, nested.getField("books"))); + } + + @Test + public void testSelectWithSubselectProjection() throws Exception { + Field books = create().select(count()) + .from(TBook()) + .where(TBook_AUTHOR_ID().equal(TAuthor_ID())).asField("books"); + + Result records = create().select(TAuthor_ID(), books) + .from(TAuthor()) + .orderBy(books, TAuthor_ID()).fetch(); + + assertEquals(2, records.size()); + assertEquals(Integer.valueOf(1), records.getValue(0, TAuthor_ID())); + assertEquals(Integer.valueOf(2), records.getValue(0, books)); + assertEquals(Integer.valueOf(2), records.getValue(1, TAuthor_ID())); + assertEquals(Integer.valueOf(2), records.getValue(1, books)); + } + @Test public void testUnaliasedSubqueryProjections() throws Exception { // TODO [#579] re-enable this test when fixing this bug diff --git a/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java b/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java index 4134e6047a..312a3c1899 100644 --- a/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java +++ b/jOOQ-test/src/org/jooq/test/jOOQAbstractTest.java @@ -1113,6 +1113,26 @@ public abstract class jOOQAbstractTest< new SelectTests(this).testSubSelect(); } + @Test + public void testSelectWithINPredicate() throws Exception { + new SelectTests(this).testSelectWithINPredicate(); + } + + @Test + public void testSelectWithExistsPredicate() throws Exception { + new SelectTests(this).testSelectWithExistsPredicate(); + } + + @Test + public void testSelectFromSelect() throws Exception { + new SelectTests(this).testSelectFromSelect(); + } + + @Test + public void testSelectWithSubselectProjection() throws Exception { + new SelectTests(this).testSelectWithSubselectProjection(); + } + @Test public void testDistinctQuery() throws Exception { new SelectTests(this).testDistinctQuery();