Skip to content

Commit 8dc6a48

Browse files
committed
store: Make infrastructure columns visible in Table::column()
Add block$ (immutable), block_range (mutable), and causality_region to the column lookup so callers that need these columns by name can find them. Also add CAUSALITY_REGION_COL pseudo-column static and tighten with_nsp visibility to pub(crate).
1 parent 298a047 commit 8dc6a48

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

store/postgres/src/relational.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use graph::prelude::{
7676
QueryExecutionError, StoreError, ValueType,
7777
};
7878

79-
use crate::block_range::{BoundSide, BLOCK_COLUMN, BLOCK_RANGE_COLUMN};
79+
use crate::block_range::{BoundSide, BLOCK_COLUMN, BLOCK_RANGE_COLUMN, CAUSALITY_REGION_COLUMN};
8080
pub use crate::catalog::Catalog;
8181
use crate::ForeignServer;
8282
use crate::{catalog, deployment, AsyncPgConnection};

store/postgres/src/relational/dsl.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::relational_queries::PARENT_ID;
3232
use super::value::FromOidRow;
3333
use super::Column as RelColumn;
3434
use super::SqlName;
35-
use super::{BLOCK_COLUMN, BLOCK_RANGE_COLUMN};
35+
use super::{BLOCK_COLUMN, BLOCK_RANGE_COLUMN, CAUSALITY_REGION_COLUMN};
3636

3737
const TYPENAME: &str = "__typename";
3838

@@ -50,6 +50,8 @@ lazy_static! {
5050
pub static ref PARENT_STRING_COL: RelColumn = RelColumn::pseudo_column(PARENT_ID, ColumnType::String);
5151
pub static ref PARENT_BYTES_COL: RelColumn = RelColumn::pseudo_column(PARENT_ID, ColumnType::Bytes);
5252
pub static ref PARENT_INT_COL: RelColumn = RelColumn::pseudo_column(PARENT_ID, ColumnType::Int8);
53+
pub static ref CAUSALITY_REGION_COL: RelColumn =
54+
RelColumn::pseudo_column(CAUSALITY_REGION_COLUMN, ColumnType::Int);
5355

5456
pub static ref META_COLS: [&'static RelColumn; 2] = [&*TYPENAME_COL, &*VID_COL];
5557
}
@@ -184,10 +186,22 @@ impl<'a> Table<'a> {
184186
/// is useful if just the name of the column qualified with the table
185187
/// name/alias is needed
186188
pub fn column(&self, name: &str) -> Option<Column<'a>> {
189+
let block_col: &RelColumn = if self.meta.immutable {
190+
&BLOCK_COL
191+
} else {
192+
&BLOCK_RANGE_COL
193+
};
194+
let cr_col: Option<&RelColumn> = if self.meta.has_causality_region {
195+
Some(&*CAUSALITY_REGION_COL)
196+
} else {
197+
None
198+
};
187199
self.meta
188200
.columns
189201
.iter()
190202
.chain(*META_COLS)
203+
.chain(std::iter::once(block_col))
204+
.chain(cr_col)
191205
.find(|c| &c.name == name)
192206
.map(|c| Column::new(*self, c))
193207
}

store/postgres/src/relational/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ impl CreateIndex {
441441
}
442442
}
443443

444-
pub fn with_nsp(&self, nsp2: String) -> Result<Self, Error> {
444+
pub(crate) fn with_nsp(&self, nsp2: String) -> Result<Self, Error> {
445445
let s = self.clone();
446446
match s {
447447
CreateIndex::Unknown { defn: _ } => Err(anyhow!("Failed to parse the index")),

0 commit comments

Comments
 (0)