Skip to content

Commit

Permalink
JDBCSyntax boolean (#789)
Browse files Browse the repository at this point in the history
  • Loading branch information
javipacheco authored Sep 25, 2024
1 parent 0d2574c commit ee1c9e8
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ class JDBCSyntax(val conn: Connection) : Connection by conn {
if (double == null) preparedStatement.setNull(index++, Types.REAL)
else preparedStatement.setDouble(index++, double)

fun bind(bool: Boolean?): Unit =
if (bool == null) preparedStatement.setNull(index++, Types.REAL)
else preparedStatement.setBoolean(index++, bool)

fun bind(string: String?): Unit =
if (string == null) preparedStatement.setNull(index++, Types.VARCHAR)
else preparedStatement.setString(index++, string)
Expand All @@ -116,6 +120,7 @@ class JDBCSyntax(val conn: Connection) : Connection by conn {
fun bytes(): ByteArray? = resultSet.getBytes(index++)
fun long(): Long? = resultSet.getLong(index++).takeUnless { resultSet.wasNull() }
fun double(): Double? = resultSet.getDouble(index++).takeUnless { resultSet.wasNull() }
fun bool(): Boolean? = resultSet.getBoolean(index++).takeUnless { resultSet.wasNull() }
fun nextRow(): Boolean = resultSet.next()
}

Expand All @@ -130,6 +135,9 @@ class JDBCSyntax(val conn: Connection) : Connection by conn {
fun double(): Double =
raise.ensureNotNull(resultSet.getDouble(index++).takeUnless { resultSet.wasNull() })

fun bool(): Boolean =
raise.ensureNotNull(resultSet.getBoolean(index++).takeUnless { resultSet.wasNull() })

fun nextRow(): Boolean = resultSet.next()
}
}

0 comments on commit ee1c9e8

Please sign in to comment.