Skip to content

The contracts of DeserializableResultset and DeserializableRow are ambiguous/underspecified #6

@regexident

Description

@regexident

The contract of DeserializableResultset and its companion DeserializableRow feels somewhat under-specified in its current form.

Ambiguity: .fieldname(_)

Any use of a bare integer-based index without an explicitly specified ordering for the collection is ambiguous:

DeserializableResultSet:

/// Returns the name of the column at the specified index.
fn fieldname(&self, field_idx: usize) -> Option<&str>;

DeserializableRow:

/// Returns the name of the column at the specified index.
fn fieldname(&self, field_idx: usize) -> Option<&str>;

As an implementor this does not tell me how I should index my result set.

The docs are also conflating "column" and "field", which just adds to the confusion: columns usually imply an ordering, while field doesn't.

Ambiguity: .next()

Without an explicit queue order any notion of "next" is ambiguous:

DeserializableResultSet:

/// Removes the next row and returns it, or None if the result set is empty, or an error.
///
/// # Errors
///
/// E.g. fetching can fail.
fn next(&mut self) -> DeserializationResult<Option<Self::Row>>;

DeserializableRow:

/// Removes and returns the next value.
fn next(&mut self) -> Option<Self::Value>;

As an implementor this does not tell me if .next() should pop from the front or from the back of the result set (assuming it is ordered).


The name DeserializableResultSet implies set-semantics, which generally describes an unordered collection with a uniqueness constraint. Neither of which are common for database, despite "result set" being in common use for database query results.

A name with less unintentional implied semantics, such as DeserializableRows might thus be a safer choice as it avoids such ambiguities and implied semantics altogether, while also making the relation between DeserializableRows and DeserializableRow as clear as can be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions