-
Notifications
You must be signed in to change notification settings - Fork 697
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
chore: Add Kdocs and update DSL for AllAnyFromBaseOp feature #1960
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,7 @@ class SelectTests : DatabaseTestsBase() { | |
|
||
@Test | ||
fun testSelectAnd() { | ||
withCitiesAndUsers { cities, users, userData -> | ||
withCitiesAndUsers { _, users, _ -> | ||
users.selectAll().where { users.id.eq("andrey") and users.name.eq("Andrey") }.forEach { | ||
val userId = it[users.id] | ||
val userName = it[users.name] | ||
|
@@ -97,7 +97,7 @@ class SelectTests : DatabaseTestsBase() { | |
|
||
@Test | ||
fun testSelectOr() { | ||
withCitiesAndUsers { cities, users, userData -> | ||
withCitiesAndUsers { _, users, _ -> | ||
users.selectAll().where { users.id.eq("andrey") or users.name.eq("Andrey") }.forEach { | ||
val userId = it[users.id] | ||
val userName = it[users.name] | ||
|
@@ -111,7 +111,7 @@ class SelectTests : DatabaseTestsBase() { | |
|
||
@Test | ||
fun testSelectNot() { | ||
withCitiesAndUsers { cities, users, userData -> | ||
withCitiesAndUsers { _, users, _ -> | ||
users.selectAll().where { not(users.id.eq("andrey")) }.forEach { | ||
val userId = it[users.id] | ||
val userName = it[users.name] | ||
|
@@ -124,7 +124,7 @@ class SelectTests : DatabaseTestsBase() { | |
|
||
@Test | ||
fun testSizedIterable() { | ||
withCitiesAndUsers { cities, users, userData -> | ||
withCitiesAndUsers { cities, users, _ -> | ||
assertEquals(false, cities.selectAll().empty()) | ||
assertEquals(true, cities.selectAll().where { cities.name eq "Qwertt" }.empty()) | ||
assertEquals(0L, cities.selectAll().where { cities.name eq "Qwertt" }.count()) | ||
|
@@ -136,7 +136,7 @@ class SelectTests : DatabaseTestsBase() { | |
|
||
@Test | ||
fun testInList01() { | ||
withCitiesAndUsers { cities, users, userData -> | ||
withCitiesAndUsers { _, users, _ -> | ||
val r = users.selectAll().where { | ||
users.id inList listOf("andrey", "alex") | ||
}.orderBy(users.name).toList() | ||
|
@@ -149,7 +149,7 @@ class SelectTests : DatabaseTestsBase() { | |
|
||
@Test | ||
fun testInList02() { | ||
withCitiesAndUsers { cities, users, userData -> | ||
withCitiesAndUsers { cities, _, _ -> | ||
val cityIds = cities.selectAll().map { it[cities.id] }.take(2) | ||
val r = cities.selectAll().where { cities.id inList cityIds } | ||
|
||
|
@@ -264,13 +264,13 @@ class SelectTests : DatabaseTestsBase() { | |
} | ||
} | ||
|
||
val testDBsSupportingInAnyAllFromTables = TestDB.postgreSQLRelatedDB + TestDB.allH2TestDB | ||
private val testDBsSupportingInAnyAllFromTables = TestDB.postgreSQLRelatedDB + TestDB.allH2TestDB | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should include MySQL8 as well, but tests will fail due to the current issue with gradle task testMySql8. A YT issue has been created to add the dialect to the tests once that issue is resolved. |
||
|
||
@Test | ||
fun testInTable() { | ||
withDb(testDBsSupportingInAnyAllFromTables) { | ||
withSalesAndSomeAmounts { _, sales, someAmounts -> | ||
val r = sales.select { sales.amount inTable someAmounts } | ||
val r = sales.selectAll().where { sales.amount inTable someAmounts } | ||
assertEquals(2, r.count()) | ||
} | ||
} | ||
|
@@ -280,42 +280,46 @@ class SelectTests : DatabaseTestsBase() { | |
fun testNotInTable() { | ||
withDb(testDBsSupportingInAnyAllFromTables) { | ||
withSalesAndSomeAmounts { _, sales, someAmounts -> | ||
val r = sales.select { sales.amount notInTable someAmounts } | ||
val r = sales.selectAll().where { sales.amount notInTable someAmounts } | ||
assertEquals(5, r.count()) | ||
} | ||
} | ||
} | ||
|
||
val testDBsSupportingAnyAndAllFromSubQuries = TestDB.values().asList() - TestDB.SQLITE | ||
val testDBsSupportingAnyAndAllFromArrays = TestDB.postgreSQLRelatedDB + TestDB.allH2TestDB | ||
private val testDBsSupportingAnyAndAllFromSubQueries = TestDB.entries - TestDB.SQLITE | ||
private val testDBsSupportingAnyAndAllFromArrays = TestDB.postgreSQLRelatedDB + TestDB.allH2TestDB | ||
|
||
/** Adapted from [testInSubQuery01]. */ | ||
@Test | ||
fun testEqAnyFromSubQuery() { | ||
withDb(testDBsSupportingAnyAndAllFromSubQuries) { | ||
withDb(testDBsSupportingAnyAndAllFromSubQueries) { | ||
withCitiesAndUsers { cities, _, _ -> | ||
val r = cities.select { cities.id eq anyFrom(cities.slice(cities.id).select { cities.id eq 2 }) } | ||
val r = cities.selectAll().where { | ||
cities.id eq anyFrom(cities.select(cities.id).where { cities.id eq 2 }) | ||
} | ||
assertEquals(1L, r.count()) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun testNeqAnyFromSubQuery() { | ||
withDb(testDBsSupportingAnyAndAllFromSubQuries) { | ||
withDb(testDBsSupportingAnyAndAllFromSubQueries) { | ||
withCitiesAndUsers { cities, _, _ -> | ||
val r = cities.select { cities.id neq anyFrom(cities.slice(cities.id).select { cities.id eq 2 }) } | ||
val r = cities.selectAll().where { | ||
cities.id neq anyFrom(cities.select(cities.id).where { cities.id eq 2 }) | ||
} | ||
assertEquals(2, r.count()) | ||
} | ||
} | ||
} | ||
|
||
/** Adapted from [testInList01]. */ | ||
@Test | ||
fun testEqAnyFromArray() { | ||
withDb(testDBsSupportingAnyAndAllFromArrays) { | ||
withCitiesAndUsers { _, users, _ -> | ||
val r = users.select { users.id eq anyFrom(arrayOf("andrey", "alex")) }.orderBy(users.name).toList() | ||
val r = users.selectAll().where { | ||
users.id eq anyFrom(arrayOf("andrey", "alex")) | ||
}.orderBy(users.name).toList() | ||
|
||
assertEquals(2, r.size) | ||
assertEquals("Alex", r[0][users.name]) | ||
|
@@ -328,7 +332,9 @@ class SelectTests : DatabaseTestsBase() { | |
fun testNeqAnyFromArray() { | ||
withDb(testDBsSupportingAnyAndAllFromArrays) { | ||
withCitiesAndUsers { _, users, _ -> | ||
val r = users.select { users.id neq anyFrom(arrayOf("andrey")) }.orderBy(users.name) | ||
val r = users.selectAll().where { | ||
users.id neq anyFrom(arrayOf("andrey")) | ||
}.orderBy(users.name) | ||
assertEquals(4, r.count()) | ||
} | ||
} | ||
|
@@ -338,7 +344,7 @@ class SelectTests : DatabaseTestsBase() { | |
fun testNeqAnyFromEmptyArray() { | ||
withDb(testDBsSupportingAnyAndAllFromArrays) { | ||
withCitiesAndUsers { _, users, _ -> | ||
val r = users.select { users.id neq anyFrom(emptyArray()) }.orderBy(users.name) | ||
val r = users.selectAll().where { users.id neq anyFrom(emptyArray()) }.orderBy(users.name) | ||
assert(r.empty()) | ||
} | ||
} | ||
|
@@ -349,7 +355,8 @@ class SelectTests : DatabaseTestsBase() { | |
withDb(testDBsSupportingAnyAndAllFromArrays) { | ||
withSales { _, sales -> | ||
val amounts = arrayOf(100, 1000).map { it.toBigDecimal() }.toTypedArray() | ||
val r = sales.select { sales.amount greaterEq anyFrom(amounts) }.orderBy(sales.amount) | ||
val r = sales.selectAll().where { sales.amount greaterEq anyFrom(amounts) } | ||
.orderBy(sales.amount) | ||
.map { it[sales.product] } | ||
assertEquals(6, r.size) | ||
r.subList(0, 3).forEach { assertEquals("tea", it) } | ||
|
@@ -358,33 +365,33 @@ class SelectTests : DatabaseTestsBase() { | |
} | ||
} | ||
|
||
/** Adapted from [testInTable]. */ | ||
@Test | ||
fun testEqAnyFromTable() { | ||
withDb(testDBsSupportingInAnyAllFromTables) { | ||
withSalesAndSomeAmounts { testDb, sales, someAmounts -> | ||
val r = sales.select { sales.amount eq anyFrom(someAmounts) } | ||
withSalesAndSomeAmounts { _, sales, someAmounts -> | ||
val r = sales.selectAll().where { sales.amount eq anyFrom(someAmounts) } | ||
assertEquals(2, r.count()) | ||
} | ||
} | ||
} | ||
|
||
/** Adapted from [testNotInTable]. */ | ||
@Test | ||
fun testNeqAllFromTable() { | ||
withDb(testDBsSupportingInAnyAllFromTables) { | ||
withSalesAndSomeAmounts { testDb, sales, someAmounts -> | ||
val r = sales.select { sales.amount neq allFrom(someAmounts) } | ||
withSalesAndSomeAmounts { _, sales, someAmounts -> | ||
val r = sales.selectAll().where { sales.amount neq allFrom(someAmounts) } | ||
assertEquals(5, r.count()) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun testGreaterEqAllFromSubQuery() { | ||
withDb(testDBsSupportingAnyAndAllFromSubQuries) { | ||
withDb(testDBsSupportingAnyAndAllFromSubQueries) { | ||
withSales { _, sales -> | ||
val r = sales.select { sales.amount greaterEq allFrom(sales.slice(sales.amount).select { sales.product eq "tea" }) } | ||
val r = sales.selectAll().where { | ||
sales.amount greaterEq allFrom(sales.select(sales.amount).where { sales.product eq "tea" }) | ||
} | ||
.orderBy(sales.amount).map { it[sales.product] } | ||
assertEquals(4, r.size) | ||
assertEquals("tea", r.first()) | ||
|
@@ -398,7 +405,7 @@ class SelectTests : DatabaseTestsBase() { | |
withDb(testDBsSupportingAnyAndAllFromArrays) { | ||
withSales { _, sales -> | ||
val amounts = arrayOf(100, 1000).map { it.toBigDecimal() }.toTypedArray() | ||
val r = sales.select { sales.amount greaterEq allFrom(amounts) }.toList() | ||
val r = sales.selectAll().where { sales.amount greaterEq allFrom(amounts) }.toList() | ||
assertEquals(3, r.size) | ||
r.forEach { assertEquals("coffee", it[sales.product]) } | ||
} | ||
|
@@ -409,7 +416,7 @@ class SelectTests : DatabaseTestsBase() { | |
fun testGreaterEqAllFromTable() { | ||
withDb(testDBsSupportingInAnyAllFromTables) { | ||
withSalesAndSomeAmounts { _, sales, someAmounts -> | ||
val r = sales.select { sales.amount greaterEq allFrom(someAmounts) }.toList() | ||
val r = sales.selectAll().where { sales.amount greaterEq allFrom(someAmounts) }.toList() | ||
assertEquals(3, r.size) | ||
r.forEach { assertEquals("coffee", it[sales.product]) } | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A YT issue has been created for the proper implementation of an array column type.