1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/// Configuration for live-query row materialization.
#[derive(Debug, Clone, Default)]
pub struct LiveRowsConfig {
/// Maximum number of rows to retain in the materialized result set.
///
/// When set, the newest rows are kept and older rows are discarded.
/// This is distinct from startup rewind settings such as `last_rows` and
/// `batch_size`, which only affect the initial snapshot sent by the server.
pub limit: Option<usize>,
/// Column names that together identify a stable row.
///
/// When omitted, live row materialization falls back to the `id` column.
pub key_columns: Option<Vec<String>>,
}
impl LiveRowsConfig {
pub(crate) fn normalized_key_columns(&self) -> Vec<String> {
let mut normalized =
Vec::with_capacity(self.key_columns.as_ref().map_or(1, |columns| columns.len().max(1)));
if let Some(columns) = &self.key_columns {
for column in columns {
let trimmed = column.trim();
if trimmed.is_empty() {
continue;
}
let normalized_column = trimmed.to_ascii_lowercase();
if normalized.iter().any(|existing| existing == &normalized_column) {
continue;
}
normalized.push(normalized_column);
}
}
if normalized.is_empty() {
normalized.push("id".to_string());
}
normalized
}
}