Skip to content
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

The method readSqlTable(connection, "table") returns different subsets of the table #494

Closed
zaleslaw opened this issue Nov 10, 2023 · 1 comment · Fixed by #500
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@zaleslaw
Copy link
Collaborator

zaleslaw commented Nov 10, 2023

From @Jolanrensen

Interestingly enough, running readSqlTable(connection, "table") with limit multiple times results in a different subset of the database. (if my first call had a limit of 100, the next time I call it it results in [100..200], then [200..300] and so on. This is again unexpected. This does not happen when running it from the console.

My comment: cursor issues

Important to add tests for repeated calls

@zaleslaw zaleslaw added the bug Something isn't working label Nov 10, 2023
@zaleslaw zaleslaw added this to the 0.12.1 milestone Nov 10, 2023
@zaleslaw zaleslaw self-assigned this Nov 10, 2023
@Jolanrensen
Copy link
Collaborator

I cannot reproduce it myself anymore, but it's good to have a test present if it ever occurs again

zaleslaw added a commit to zaleslaw/dataframe that referenced this issue Nov 13, 2023
Tests were added to the h2Test to cover cases reported in issues Kotlin#494 and Kotlin#498 in the DataFrame. Furthermore, SQL query validation in DataFrame.readSqlQuery was softened to accept SELECT statements only, removing other restrictions that checked against DDL or DML or DCL operators. New test cases were introduced to ensure that unexpected SQL statements result in thrown IllegalArgumentExceptions, improving overall robustness.
zaleslaw added a commit that referenced this issue Nov 13, 2023
* Add validation for SQL queries in DataFrame.readSqlQuery

A validation function has been added to DataFrame.readSqlQuery to handle cases where an inappropriate SQL query is passed. The function verifies that the SQL query starts with "SELECT" and doesn't contain any other DDL, DML, or DCL operators to prevent data manipulation. Corresponding test cases were also added in h2Test to ensure that an IllegalArgumentException is thrown when the SQL query is incorrect.

* Add tests for SQL commit and refine validation

Tests were added to the h2Test to cover cases reported in issues #494 and #498 in the DataFrame. Furthermore, SQL query validation in DataFrame.readSqlQuery was softened to accept SELECT statements only, removing other restrictions that checked against DDL or DML or DCL operators. New test cases were introduced to ensure that unexpected SQL statements result in thrown IllegalArgumentExceptions, improving overall robustness.

* Add constants for SQL read query start and separator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants