-
Notifications
You must be signed in to change notification settings - Fork 1
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 Internal Server Error When Filtering by String Column but the value can be interpreted as another type #36
Open
Antonio171003
wants to merge
4
commits into
wiringbits:main
Choose a base branch
from
Antonio171003:filtering-by-non-string-column
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2ec495a
Fixed an Internal Server Error, Caused when attempting to filter by a…
Antonio171003 6e2c5ac
Added tests and corrections
Antonio171003 e270d6c
Merge branch 'main' into filtering-by-non-string-column
AlexITC 0546ae0
Merge branch 'main' into filtering-by-non-string-column
AlexITC 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
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 = "[email protected]" | ||
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 { | ||
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 = "[email protected]" | ||
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 { | ||
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 = "[email protected]" | ||
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 { | ||
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 = "[email protected]" | ||
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 { | ||
|
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.
When the value is CITEXT we should interpret it as string, any reason to interpret it as int?
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.