Skip to content

Commit

Permalink
recursively go through each generated from columns in case they're al…
Browse files Browse the repository at this point in the history
…so generated
  • Loading branch information
jeromegn committed Aug 29, 2024
1 parent 93ed989 commit 5aa8dc6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions crates/corro-types/src/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use crate::{
agent::SplitPool,
api::QueryEvent,
base::CrsqlDbVersion,
schema::{Schema, Table},
schema::{Generated, Schema, Table},
sqlite::CrConn,
};

Expand Down Expand Up @@ -1925,12 +1925,14 @@ fn extract_select_columns(select: &Select, schema: &Schema) -> Result<ParsedSele
}

fn insert_col(set: &mut HashSet<String>, schema: &Schema, tbl_name: &str, name: &str) {
if let Some(generated) = schema
.tables
.get(tbl_name)
.and_then(|tbl| tbl.columns.get(name).and_then(|col| col.generated.as_ref()))
let table = schema.tables.get(tbl_name);
if let Some(generated) =
table.and_then(|tbl| tbl.columns.get(name).and_then(|col| col.generated.as_ref()))
{
set.extend(generated.from.clone());
// recursively check for generated columns
for name in generated.from.iter() {
insert_col(set, schema, tbl_name, name);
}
} else {
set.insert(name.to_owned());
}
Expand Down

0 comments on commit 5aa8dc6

Please sign in to comment.