-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EXPOSED-353 dateLiteral does not work on OracleDB 12c or 19c #1338
- Loading branch information
1 parent
d3c5dbc
commit 1e43634
Showing
2 changed files
with
47 additions
and
1 deletion.
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
39 changes: 39 additions & 0 deletions
39
exposed-java-time/src/test/kotlin/org/jetbrains/exposed/DateLiteralTest.kt
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.jetbrains.exposed | ||
|
||
import junit.framework.TestCase.assertNull | ||
import org.jetbrains.exposed.DateLiteralTest.TableWithDate.date | ||
import org.jetbrains.exposed.dao.id.IntIdTable | ||
import org.jetbrains.exposed.sql.insert | ||
import org.jetbrains.exposed.sql.javatime.date | ||
import org.jetbrains.exposed.sql.javatime.dateLiteral | ||
import org.jetbrains.exposed.sql.selectAll | ||
import org.jetbrains.exposed.sql.tests.DatabaseTestsBase | ||
import org.jetbrains.exposed.sql.tests.shared.assertEquals | ||
import org.junit.Test | ||
import java.time.LocalDate | ||
|
||
class DateLiteralTest : DatabaseTestsBase() { | ||
object TableWithDate : IntIdTable() { | ||
val date = date("date") | ||
} | ||
|
||
@Test | ||
fun testDateLiteralInQuery() { | ||
withTables(TableWithDate) { | ||
val future = LocalDate.of(3000, 1, 1) | ||
val past = LocalDate.of(1500, 1, 1) | ||
|
||
TableWithDate.insert { | ||
it[date] = future | ||
} | ||
|
||
assertEquals(future, TableWithDate.selectAll().first()[date]) | ||
|
||
assertEquals(future, TableWithDate.selectAll().where { date greater past }.first()[date]) | ||
|
||
assertEquals(future, TableWithDate.selectAll().where { date greater dateLiteral(past) }.first()[date]) | ||
|
||
assertNull(TableWithDate.selectAll().where { date less dateLiteral(past) }.firstOrNull()) | ||
} | ||
} | ||
} |