Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Fix Internal Server Error When Filtering by String Column but the value can be interpreted as another type#36
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
2ec495a6e2c5ace270d6c0546ae0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -532,6 +532,106 @@ class AdminControllerSpec extends PlayPostgresSpec with AdminUtils { | ||
| .futureValue | ||
| response.headOption.isEmpty must be(true) | ||
| } | ||
| "don't fail when the column is citext or similar, but the value can be interpreted as Int." in withApiClient { | ||
| client => | ||
| val name = "wiringbits" | ||
| val email = "test17@wiringbits.net" | ||
| val request = AdminCreateTable.Request( | ||
| Map("name" -> name, "email" -> email, "password" -> "wiringbits") | ||
| ) | ||
| client.createItem(usersSettings.tableName, request).futureValue | ||
| val response = client | ||
| .getTableMetadata( | ||
| usersSettings.tableName, | ||
| List("email", "ASC"), | ||
| List(0, 9), | ||
| """{"email":"17"}""" | ||
| ) | ||
| .futureValue | ||
| val head = response.headOption.value | ||
| val nameValue = head.find(_._1 == "name").value._2 | ||
| val emailValue = head.find(_._1 == "email").value._2 | ||
| response.size must be(1) | ||
| name must be(nameValue) | ||
| email must be(emailValue) | ||
| } | ||
| "don't fail when the column is citext or similar, but the value can be interpreted as Decimal." in withApiClient { | ||
Contributor 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. Same | ||
| client => | ||
| val name = "wiringbits" | ||
| val email = "test17.10@wiringbits.net" | ||
| val request = AdminCreateTable.Request( | ||
| Map("name" -> name, "email" -> email, "password" -> "wiringbits") | ||
| ) | ||
| client.createItem(usersSettings.tableName, request).futureValue | ||
| val response = client | ||
| .getTableMetadata( | ||
| usersSettings.tableName, | ||
| List("email", "ASC"), | ||
| List(0, 9), | ||
| """{"email":"17.10"}""" | ||
| ) | ||
| .futureValue | ||
| val head = response.headOption.value | ||
| val nameValue = head.find(_._1 == "name").value._2 | ||
| val emailValue = head.find(_._1 == "email").value._2 | ||
| response.size must be(1) | ||
| name must be(nameValue) | ||
| email must be(emailValue) | ||
| } | ||
| "don't fail when the column is citext or similar, but the value can be interpreted as Date." in withApiClient { | ||
Contributor 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. Same | ||
| client => | ||
| val name = "wiringbits" | ||
| val email = "test2024-06-06@wiringbits.net" | ||
| val request = AdminCreateTable.Request( | ||
| Map("name" -> name, "email" -> email, "password" -> "wiringbits") | ||
| ) | ||
| client.createItem(usersSettings.tableName, request).futureValue | ||
| val response = client | ||
| .getTableMetadata( | ||
| usersSettings.tableName, | ||
| List("email", "ASC"), | ||
| List(0, 9), | ||
| """{"email":"2024-06"}""" | ||
| ) | ||
| .futureValue | ||
| val head = response.headOption.value | ||
| val nameValue = head.find(_._1 == "name").value._2 | ||
| val emailValue = head.find(_._1 == "email").value._2 | ||
| response.size must be(1) | ||
| name must be(nameValue) | ||
| email must be(emailValue) | ||
| } | ||
| "don't fail when the column is citext or similar, but the value can be interpreted as UUID." in withApiClient { | ||
Contributor 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. Same | ||
| client => | ||
| val name = "wiringbits" | ||
| val email = "8c861a28-e384-4a9b-b7c2-a0367aa3f3e8@wiringbits.net" | ||
| val request = AdminCreateTable.Request( | ||
| Map("name" -> name, "email" -> email, "password" -> "wiringbits") | ||
| ) | ||
| client.createItem(usersSettings.tableName, request).futureValue | ||
| val response = client | ||
| .getTableMetadata( | ||
| usersSettings.tableName, | ||
| List("name", "ASC"), | ||
| List(0, 9), | ||
| """{"email":"8c861a28-e384-4a9b-b7c2-a0367aa3f3e8"}""" | ||
| ) | ||
| .futureValue | ||
| val head = response.headOption.value | ||
| val nameValue = head.find(_._1 == "name").value._2 | ||
| val emailValue = head.find(_._1 == "email").value._2 | ||
| response.size must be(1) | ||
| name must be(nameValue) | ||
| email must be(emailValue) | ||
| } | ||
| } | ||
| "GET /admin/tables/:tableName/:primaryKey" should { | ||
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.
When the value is CITEXT we should interpret it as string, any reason to interpret it as int?
Uh oh!
There was an error while loading. Please reload this page.
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.
Before, if the value was "123", it was assumed that the value was an Int, and the same for the column type. This caused an internal server error because it compared a citext with an Int.
Same for the others comments
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.
From my point of view, the input argument must be handled like the type derived from the database instead of guessing its format.
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.
Yes, the changes in this pull request consider both the column type and the value to avoid this.