Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

First draft of a dynamic select clause feature in diesel-dynamic-schema #10

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ impl<T, U, ST> Column<T, U, ST> {
_sql_type: PhantomData,
}
}

/// Gets a reference to the table of the column.
pub fn table(&self) -> &T {
&self.table
}

/// Gets the name of the column, as provided on creation.
pub fn name(&self) -> &U {
&self.name
}
}

impl<T, U, ST> QueryId for Column<T, U, ST> {
Expand Down
5 changes: 5 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ impl<T> Schema<T> {
Self { name }
}

/// Gets the name of the schema, as specified on creation.
pub fn name(&self) -> &T {
&self.name
}

/// Create a table with this schema.
pub fn table<U>(&self, name: U) -> Table<U, T>
where
Expand Down
7 changes: 6 additions & 1 deletion src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ impl<T, U> Table<T, U> {
Self { name, schema: None }
}

/// Gets the name of the column, as especified on creation.
pub fn name(&self) -> &T {
&self.name
}

pub(crate) fn with_schema(schema: U, name: T) -> Self {
Self {
name,
schema: Some(schema),
}
}

/// Create a column with this table.
/// Creates a column with this table.
pub fn column<ST, V>(&self, name: V) -> Column<Self, V, ST>
where
Self: Clone,
Expand Down