Skip to content

feat: add support for bool fields #63

Open
@chrissuozzo

Description

@chrissuozzo

The proposed feature would allow a table containing BOOLEAN columns to be represented as bool fields within a user's row structure. For example, if you have this table with the BOOLEAN column bool_value:

CREATE TABLE sometable (
  id INTEGER NOT NULL,
  bool_value BOOLEAN NOT NULL,
  PRIMARY KEY (id)
);

You could then represent the row as:

#[derive(Debug, serde::Deserialize)]
struct SomeTableRow {
  id: i64,
  bool_value: bool,
}

The following query would then work as expected:

let rows = db
     .execute("SELECT * FROM sometable")
     .await?
     .rows
     .iter()
     .map(de::from_row)
     .collect::<Result<Vec<SomeTableRow>, _>>()?;

Currently, the above query will result in a runtime error due to the inability to coerce the native 0/1 integer value to bool:

Error: invalid type: integer `1`, expected a boolean
error: process didn't exit successfully: `target\debug\test.exe` (exit code: 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions