forked from 2sys/phonograph
39 lines
1.3 KiB
Rust
39 lines
1.3 KiB
Rust
|
|
use diesel::{
|
||
|
|
dsl::{AsSelect, auto_type},
|
||
|
|
pg::Pg,
|
||
|
|
prelude::*,
|
||
|
|
};
|
||
|
|
|
||
|
|
use crate::catalogs_schema::table_privileges;
|
||
|
|
|
||
|
|
pub use crate::catalogs_schema::table_privileges::{dsl, table};
|
||
|
|
|
||
|
|
#[derive(Clone, Debug, Queryable, Selectable)]
|
||
|
|
#[diesel(table_name = table_privileges)]
|
||
|
|
pub struct TablePrivilege {
|
||
|
|
/// Name of the role that granted the privilege
|
||
|
|
grantor: String,
|
||
|
|
/// Name of the role that the privilege was granted to
|
||
|
|
grantee: String,
|
||
|
|
/// Name of the database that contains the table (always the current database)
|
||
|
|
table_catalog: String,
|
||
|
|
/// Name of the schema that contains the table
|
||
|
|
table_schema: String,
|
||
|
|
/// Name of the table
|
||
|
|
table_name: String,
|
||
|
|
/// Type of the privilege: SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, or TRIGGER
|
||
|
|
privilege_type: String,
|
||
|
|
/// YES if the privilege is grantable, NO if not
|
||
|
|
is_grantable: String,
|
||
|
|
/// In the SQL standard, WITH HIERARCHY OPTION is a separate (sub-)privilege allowing certain operations on table inheritance hierarchies. In PostgreSQL, this is included in the SELECT privilege, so this column shows YES if the privilege is SELECT, else NO.
|
||
|
|
with_hierarchy: String,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl TablePrivilege {
|
||
|
|
#[auto_type(no_type_alias)]
|
||
|
|
pub fn all() -> _ {
|
||
|
|
let select: AsSelect<Self, Pg> = Self::as_select();
|
||
|
|
table.select(select)
|
||
|
|
}
|
||
|
|
}
|