-
Notifications
You must be signed in to change notification settings - Fork 695
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
fix(DoubleColumnType): correctly handle precision when casting Float to DoubleColumnType for a real
column
#2115
Merged
bog-walk
merged 4 commits into
JetBrains:main
from
jackgisel-RL:jackgisel-rl/fix-bug-with-decimal-column-type
Jun 6, 2024
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
26 changes: 26 additions & 0 deletions
26
...sts/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/types/DoubleColumnTypeTests.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,26 @@ | ||
package org.jetbrains.exposed.sql.tests.shared.types | ||
|
||
import org.jetbrains.exposed.dao.id.IntIdTable | ||
import org.jetbrains.exposed.sql.* | ||
import org.jetbrains.exposed.sql.tests.DatabaseTestsBase | ||
import org.jetbrains.exposed.sql.tests.shared.assertEquals | ||
import org.junit.Test | ||
|
||
class DoubleColumnTypeTests : DatabaseTestsBase() { | ||
object TestTable : IntIdTable("double_table") { | ||
val amount = double("amount") | ||
} | ||
|
||
@Test | ||
fun `test correctly gets data from the DB`() { | ||
withTables(TestTable) { | ||
val id = TestTable.insertAndGetId { | ||
it[amount] = 9.23 | ||
} | ||
|
||
TestTable.selectAll().where { TestTable.id eq id }.singleOrNull()?.let { | ||
assertEquals(9.23, it[TestTable.amount]) | ||
} | ||
} | ||
} | ||
} |
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.
This tests passes without the fix, understandably because the create DDL is using DOUBLE PRECISION for all DB, which doesn't match your failing use case.
It's ok to leave this test as a control, but please add a second test that uses a REAL column instead, which will fail without the fix. Something like this:
Also, please change the name of the first test to use camelCase and be a bit more descriptive, anything like for example:
testInsertAndSelectFromDoubleColumn
. This naming convention more easily allows us to potentially add tests as samples in our KDocs in the future.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.
ah thanks for providing that test case! i wanted to do this, but couldn't find the correctly way to get the column type, thanks!! updating now!