Skip to content

Commit 70d8309

Browse files
authored
Merge pull request diesel-rs#2504 from Razican/dynamic_table_name
Added getters for dynamic tables, columns and schemas
2 parents 702d322 + 469e1ae commit 70d8309

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

diesel_dynamic_schema/src/column.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ impl<T, U, ST> Column<T, U, ST> {
2525
_sql_type: PhantomData,
2626
}
2727
}
28+
29+
/// Gets a reference to the table of the column.
30+
pub fn table(&self) -> &T {
31+
&self.table
32+
}
33+
34+
/// Gets the name of the column, as provided on creation.
35+
pub fn name(&self) -> &U {
36+
&self.name
37+
}
2838
}
2939

3040
impl<T, U, ST> QueryId for Column<T, U, ST> {

diesel_dynamic_schema/src/schema.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ impl<T> Schema<T> {
1919
{
2020
Table::with_schema(self.name.clone(), name)
2121
}
22+
23+
/// Gets the name of the schema, as specified on creation.
24+
pub fn name(&self) -> &T {
25+
&self.name
26+
}
2227
}

diesel_dynamic_schema/src/table.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ impl<T, U> Table<T, U> {
3535
{
3636
Column::new(self.clone(), name)
3737
}
38+
39+
/// Gets the name of the table, as especified on creation.
40+
pub fn name(&self) -> &T {
41+
&self.name
42+
}
3843
}
3944

4045
impl<T, U> QuerySource for Table<T, U>

0 commit comments

Comments
 (0)