Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UDT support for prepared statements
Update the latte's 'to_scylla_value' function (which is used by the 'execute_prepared' one) to support CQL UserDefinedTypes. If we create UDT like following: let KEYSPACE = "fooks" let UDT_NAME = "fooudt" context.execute(`CREATE TYPE IF NOT EXISTS ${KEYSPACE}.${UDT_NAME} ( id bigint, textk1 text, textk2 text)`).await?; And then use it in some table. Then, with this change, we can use the 'rune::runtime::Object' object defined like following: let udtexample = #{ "_keyspace": KEYSPACE, "_type_name": UDT_NAME, "id": fooid, "textk1": textv1, "textk2": textv2 }; in an 'execute_prepared' function. Note that '_keyspace' and '_type_name' are special and required fields which are used to satisfy the Scylla Rust driver's "CqlValue::UserDefinedType" object structure: pub enum CqlValue { ... UserDefinedType { keyspace: String, type_name: String, /// Order of `fields` vector must match the order of fields as defined in the UDT. The /// driver does not check it by itself, so incorrect data will be written if the order is /// wrong. fields: Vec<(String, Option<CqlValue>)>, }, ... Also, note that for proper workability of various sub-types of the UDT such as `bigint` for the example `id` field mentioned above need to use Scylla-rust driver '0.11' or newer.
- Loading branch information