diff --git a/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Versions.kt b/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Versions.kt index 24b09e7739..8bbe0e5dc4 100644 --- a/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Versions.kt +++ b/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Versions.kt @@ -18,7 +18,7 @@ object Versions { const val oracle12 = "12.2.0.1" const val postgre = "42.4.0" const val postgreNG = "0.8.9" - const val sqlLite3 = "3.36.0.3" + const val sqlLite3 = "3.43.0.0" const val sqlserver = "9.4.1.jre8" /** Spring **/ diff --git a/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcConnectionImpl.kt b/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcConnectionImpl.kt index a1ae0d3ad9..4ae31e1116 100644 --- a/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcConnectionImpl.kt +++ b/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcConnectionImpl.kt @@ -74,11 +74,19 @@ class JdbcConnectionImpl(override val connection: Connection) : ExposedConnectio } else { PreparedStatement.NO_GENERATED_KEYS } - return JdbcPreparedStatementImpl(connection.prepareStatement(sql, generated), returnKeys) + return JdbcPreparedStatementImpl( + connection.prepareStatement(sql, generated), + returnKeys, + connection.metaData.supportsGetGeneratedKeys() + ) } override fun prepareStatement(sql: String, columns: Array): PreparedStatementApi { - return JdbcPreparedStatementImpl(connection.prepareStatement(sql, columns), true) + return JdbcPreparedStatementImpl( + connection.prepareStatement(sql, columns), + true, + connection.metaData.supportsGetGeneratedKeys() + ) } override fun executeInBatch(sqls: List) { diff --git a/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcPreparedStatementImpl.kt b/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcPreparedStatementImpl.kt index e6edcac443..04d3fec5a5 100644 --- a/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcPreparedStatementImpl.kt +++ b/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/sql/statements/jdbc/JdbcPreparedStatementImpl.kt @@ -4,14 +4,24 @@ import org.jetbrains.exposed.sql.BinaryColumnType import org.jetbrains.exposed.sql.BlobColumnType import org.jetbrains.exposed.sql.IColumnType import org.jetbrains.exposed.sql.statements.api.PreparedStatementApi +import org.jetbrains.exposed.sql.vendors.SQLiteDialect +import org.jetbrains.exposed.sql.vendors.currentDialect import java.io.InputStream import java.sql.PreparedStatement import java.sql.ResultSet import java.sql.Types -class JdbcPreparedStatementImpl(val statement: PreparedStatement, val wasGeneratedKeysRequested: Boolean) : PreparedStatementApi { +class JdbcPreparedStatementImpl(val statement: PreparedStatement, val wasGeneratedKeysRequested: Boolean, private val supportsGetGeneratedKeys: Boolean) : PreparedStatementApi { override val resultSet: ResultSet? - get() = if (wasGeneratedKeysRequested) statement.generatedKeys else statement.resultSet + get() = if (wasGeneratedKeysRequested) { + if (supportsGetGeneratedKeys) { + statement.generatedKeys + } else if (currentDialect is SQLiteDialect) { + statement.connection.prepareStatement("select last_insert_rowid();").executeQuery() + } else { + statement.resultSet + } + } else statement.resultSet override var fetchSize: Int? get() = statement.fetchSize