Skip to content

Commit 50de226

Browse files
authored
feat: restore TableRef::table_id (#1001)
This is a simple method that was accidentally removed. Now let's add it back.
1 parent d32b28e commit 50de226

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

crates/proof-of-sql/src/base/database/table_ref.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ impl TableRef {
4848
}
4949
}
5050

51-
/// Returns the identifier of the schema
52-
/// # Panics
51+
/// Returns the identifier of the schema if it exists. Otherwise returns `None`.
5352
#[must_use]
5453
pub fn schema_id(&self) -> Option<&Ident> {
5554
match self {
@@ -58,6 +57,17 @@ impl TableRef {
5857
}
5958
}
6059

60+
/// Returns the identifier of the table if it exists. Otherwise returns `None`.
61+
#[must_use]
62+
pub fn table_id(&self) -> Option<&Ident> {
63+
match self {
64+
Self::FullyQualified { table_name, .. } | Self::TableOnly { table_name } => {
65+
Some(table_name)
66+
}
67+
Self::None => None,
68+
}
69+
}
70+
6171
/// Creates a new table reference from an optional schema and table name.
6272
#[must_use]
6373
pub fn from_names(schema_name: Option<&str>, table_name: &str) -> Self {

0 commit comments

Comments
 (0)