-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Diesel, the Rust crate being migrated to for interfacing with recording in SQLite .db3, enables the use of custom sql_functions which can also be implemented in rust:
http://docs.diesel.rs/diesel/macro.sql_function.html#use-with-sqlite
I'm still unsure how to formulate a SQL query that could loop over all rows given a topic_id (A vs B) in the messages (1,2,...,N) table such that it could replicate a hash chain as follows in (9) and (10):
An example of specifying a .filter() query using the topic_id as a criteria is as follows:
bbr_ros2/bbr_cli/src/api/mod.rs
Lines 119 to 123 in a9f0780
| use crate::schema::messages::dsl::topic_id; | |
| let message_results = messages::table | |
| .filter(topic_id.eq(topic_result.id)) | |
| .load::<message::Message>(&conn) | |
| .expect("Error loading messages"); |
Would it be possible to replicate something like a LAG function (guessing here?) over filter query and feed that into a custom function in SQL sequentially? Is this even possible in SQLite?
https://www.sqlitetutorial.net/sqlite-window-functions/sqlite-lag/
bbr_ros2/bbr_cli/migrations/create_tabels/up.sql
Lines 8 to 13 in a9f0780
| CREATE TABLE messages( | |
| id INTEGER PRIMARY KEY NOT NULL, | |
| topic_id INTEGER NOT NULL, | |
| timestamp INTEGER NOT NULL, | |
| data BLOB NOT NULL, | |
| bbr_digest BLOB); |
Relates to: diesel-rs/diesel#1775 , cc @weiznich
