Make SimpleStatement and QueryBuilder "detached" again

Description

RegularStatement implementations need access to the protocol version and codec registry for certain operations (serialize their values, inline values in built statements, etc.).

In 3.0, we initially solved that problem by making these types "attached" to a specific session, which changes the way to create them: Session#newSimpleStatement (instead of a constructor) and new QueryBuilder(session) (instead of static methods).

In hindsight this will be quite annoying when migrating from 2.1 to 3.0, and inconvenient for special cases like unit tests. I think it's better to go back to passing the protocol version and codec registry to methods that need them, and in some cases provide no-arg versions with sensible defaults for people who will not use custom codecs, or will register them against the default registry.

Environment

None

Pull Requests

None

Activity

Show:
Olivier Michallat
December 8, 2015, 9:49 AM

Reverted to new SimpleStatement(...) and static QueryBuilder methods.

As a consequence, the following methods were refactored:

  • `Statement`. The following public methods were modified:

    • `getRoutingKey(ProtocolVersion, CodecRegistry)`: both parameters added.

  • `RegularStatement`. The following public methods were modified:

    • `getValues(ProtocolVersion, CodecRegistry)`: second parameter added.

    • `getQueryString(CodecRegistry)` and `hasValues(CodecRegistry)`: parameter added. No-arg versions are still present
      and use the default codec registry; refer to the Javadocs for guidance on which version to use.

Fixed

Assignee

Unassigned

Reporter

Olivier Michallat

Labels

None

PM Priority

None

Affects versions

None

Fix versions

Pull Request

None

Doc Impact

None

Size

None

External issue ID

None

External issue ID

None

Priority

Minor
Configure