Skip to content

Implement Session::insert #1295

Open
Open
@Lorak-mmk

Description

@Lorak-mmk

After our paging API refactor there are now 3 main request execution methods on Session:

  • execute_unpaged
  • execute_single_page
  • execute_iter

This distinction makes sense for SELECT requests, where the type of paging is something important to consider.

There is unfortunately an ergonomics problem: when INSERTing / UPDATing data paging has no relevance at all, but the user has to choose one of the above methods anyway - usually execute_unpaged. This does not look nice in the code.

We could improve this by adding Session::insert, which would return error if the received response contains rows.

LWT Inserts

There is one problem: What about LWT inserts? They do return rows, so it would not be possible to execute them using this new method.
We could allow rows response for insert if PreparedStatement::is_confirmed_lwt is true. This would only work for Scylla - Cassandra does not have this extension. This would unfortunately cause insert to also allow LWT SELECTs. I don't see a good solution here, unless we want to do some heuristic statement parsing.

Maybe allowing LWT SELECTs is acceptable? Do those even support paging?

Naming

execute_insert vs insert: I'd strongly favor the latter because of ergonomics. I don't think we need similar method for unprepared statements, so there should be no need for execute_ prefix.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions