Skip to content

Fix bug that prevented SQL Server row limts #1136

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

Merged
merged 1 commit into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public object MsSql : DbType("sqlserver") {
override fun convertSqlTypeToKType(tableColumnMetadata: TableColumnMetadata): KType? = null

public override fun sqlQueryLimit(sqlQuery: String, limit: Int): String {
sqlQuery.replace("SELECT", "SELECT TOP $limit", ignoreCase = true)
return sqlQuery
return sqlQuery.replace("SELECT", "SELECT TOP $limit", ignoreCase = true)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.jetbrains.kotlinx.dataframe.io

import io.kotest.matchers.shouldBe
import org.intellij.lang.annotations.Language
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.annotations.DataSchema
import org.jetbrains.kotlinx.dataframe.api.cast
import org.jetbrains.kotlinx.dataframe.api.filter
import org.jetbrains.kotlinx.dataframe.io.db.MsSql
import org.junit.AfterClass
import org.junit.BeforeClass
import org.junit.Test
import java.sql.Connection
import java.sql.DriverManager
import java.sql.SQLException
import kotlin.reflect.typeOf

class MsSqlTest {
companion object {
@BeforeClass
@JvmStatic
fun setUpClass() {
}

@AfterClass
@JvmStatic
fun tearDownClass() {
}
}

@Test
fun `test SQL Server TOP limit functionality`() {
MsSql.sqlQueryLimit("SELECT * FROM TestTable1", 1) shouldBe "SELECT TOP 1 * FROM TestTable1"
}
}