Skip to content

Extract SqliteNumericText and collapse the duplicate numeric getters #200

Closed

Description

@magnusp

Goal

Move SQLite text-to-number parsing out of LibsqlResultSet, and collapse the two duplicated getter ladders. getInt repeats toLong plus a cast, and getFloat repeats toDouble plus a cast.

Depends on

#199. Same file.

Pin

LibsqlResultSetTest covers non-numeric text, numeric prefixes, leading whitespace and trailing garbage, exponent rules, BLOB coercion, int64 wrapping, and float rounding. LibsqlResultSetGetBooleanTest covers the boolean route.

Scope

  • Create SqliteNumericText with parseLong, parseDouble, and blobAsText from LibsqlResultSet 521 to 624.
  • Move toLong and toDouble or keep them in the result set and delegate. Keep one definition of each.
  • getInt becomes (int) toLong(getCurrentValue(columnIndex)).
  • getFloat becomes (float) toDouble(getCurrentValue(columnIndex)).

Preserve

  • Overflow saturates to Long.MIN_VALUE or Long.MAX_VALUE.
  • Parsing takes a numeric prefix only. An exponent counts only when at least one digit follows it. Failure yields 0 or 0.0.
  • The whitespace set is space, \t, \n, \r, vertical tab, form feed. Do not use Character.isWhitespace.
  • getBoolean keeps routing through getInt, so a REAL 0.5 is false.

Acceptance

  • SqliteNumericText.java exists, and each numeric getter is one delegation plus its cast.
  • LibsqlResultSet.java is under 950 lines.
  • ./mvnw -pl libsql-jdbc -am test green with no assertion edited.
  • ./mvnw spotless:check green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions