Skip to content

Bug in MsSql.sqlQueryLimit #1135

@TomMicheline

Description

@TomMicheline

I discovered that any time I tried to get the schema of a large table (large number of rows not columns), it would work much too long and then eventually fail when heap memory was exhausted. However, after moving my code out of a notebook and into standalone code it was pretty easy to find in the debugger. The SQL Server sqlQueryLimit() function correctly inserted the TOP clause but then threw the altered string away and returned the original string:

   public override fun sqlQueryLimit(sqlQuery: String, limit: Int): String {
        sqlQuery.replace("SELECT", "SELECT TOP $limit", ignoreCase = true)
        return sqlQuery
    }

String.replace() returns the altered string. I forked, created a unit test, and fixed the bug. I'll be submitting a PR immediately after posting this.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdatabasesJDBC related issues

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions