Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
Clippy cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
chotchki committed Sep 4, 2021
1 parent cfc325b commit 2370aaa
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 72 deletions.
30 changes: 15 additions & 15 deletions src/constants/system_tables/pg_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@ use hex_literal::hex;
use std::sync::Arc;
use uuid::Uuid;

pub const id: Uuid = Uuid::from_bytes(hex!("EE89957F3E9F482C836DDA6C349AC632"));
pub const name: &str = "pg_attribute";
pub const ID: Uuid = Uuid::from_bytes(hex!("EE89957F3E9F482C836DDA6C349AC632"));
pub const NAME: &str = "pg_attribute";

pub const column_class_id: &str = "class_id";
pub const column_name: &str = "name";
pub const column_sql_type: &str = "type_name";
pub const column_column_num: &str = "column_num";
pub const column_nullable: &str = "nullable";
pub const COLUMN_CLASS_ID: &str = "class_id";
pub const COLUMN_NAME: &str = "name";
pub const COLUMN_SQL_TYPE: &str = "type_name";
pub const COLUMN_COLUMN_NUM: &str = "column_num";
pub const COLUMN_NULLABLE: &str = "nullable";

pub fn get_columns() -> Vec<Attribute> {
vec![
Attribute::new(
column_class_id.to_string(),
COLUMN_CLASS_ID.to_string(),
BaseSqlTypesMapper::Uuid,
Nullable::NotNull,
None,
),
Attribute::new(
column_name.to_string(),
COLUMN_NAME.to_string(),
BaseSqlTypesMapper::Text,
Nullable::NotNull,
None,
),
Attribute::new(
column_sql_type.to_string(),
COLUMN_SQL_TYPE.to_string(),
BaseSqlTypesMapper::Text, //TODO join to pg_type instead, for now its a string
Nullable::NotNull,
None,
),
Attribute::new(
column_column_num.to_string(),
COLUMN_COLUMN_NUM.to_string(),
BaseSqlTypesMapper::Integer,
Nullable::NotNull,
None,
),
Attribute::new(
column_nullable.to_string(),
COLUMN_NULLABLE.to_string(),
BaseSqlTypesMapper::Bool,
Nullable::NotNull,
None,
Expand All @@ -54,7 +54,7 @@ pub fn get_columns() -> Vec<Attribute> {
pub fn get_index(attrs: &Vec<Attribute>) -> Arc<Index> {
Arc::new(Index {
id: Uuid::from_bytes(hex!("516B20412CF145A2AD9E39A8BDEB30A8")),
name: name.to_string() + "_name_index",
name: NAME.to_string() + "_name_index",
columns: Arc::new(SqlTypeDefinition::new(&[attrs[1].clone()])),
unique: true,
})
Expand All @@ -64,8 +64,8 @@ pub fn get_table() -> Arc<Table> {
let columns = get_columns();
let index = get_index(&columns);
Arc::new(Table::new(
id,
name.to_string(),
ID,
NAME.to_string(),
get_columns(),
vec![Constraint::PrimaryKey(PrimaryKeyConstraint {
name: index.name.clone() + "_primary_key",
Expand Down
20 changes: 10 additions & 10 deletions src/constants/system_tables/pg_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ use hex_literal::hex;
use std::sync::Arc;
use uuid::Uuid;

pub const id: Uuid = Uuid::from_bytes(hex!("EE919E33D9054F4889537EBB6CC911EB"));
pub const name: &str = "pg_class";
pub const ID: Uuid = Uuid::from_bytes(hex!("EE919E33D9054F4889537EBB6CC911EB"));
pub const NAME: &str = "pg_class";

pub const column_id: &str = "id";
pub const column_name: &str = "name";
pub const COLUMN_ID: &str = "id";
pub const COLUMN_NAME: &str = "name";

pub fn get_columns() -> Vec<Attribute> {
vec![
Attribute::new(
column_id.to_string(),
COLUMN_ID.to_string(),
BaseSqlTypesMapper::Uuid,
Nullable::NotNull,
None,
),
Attribute::new(
column_name.to_string(),
COLUMN_NAME.to_string(),
BaseSqlTypesMapper::Text,
Nullable::NotNull,
None,
Expand All @@ -33,7 +33,7 @@ pub fn get_columns() -> Vec<Attribute> {
pub fn get_index(attrs: &Vec<Attribute>) -> Arc<Index> {
Arc::new(Index {
id: Uuid::from_bytes(hex!("516B20412CF145A2AD9E39A8BDEB30A8")),
name: name.to_string() + "_name_index",
name: NAME.to_string() + "_name_index",
columns: Arc::new(SqlTypeDefinition::new(&[attrs[1].clone()])),
unique: true,
})
Expand All @@ -43,11 +43,11 @@ pub fn get_table() -> Arc<Table> {
let columns = get_columns();
let index = get_index(&columns);
Arc::new(Table::new(
id,
name.to_string(),
ID,
NAME.to_string(),
columns,
vec![Constraint::PrimaryKey(PrimaryKeyConstraint {
name: name.to_string() + "_primary_key",
name: NAME.to_string() + "_primary_key",
index: index.clone(),
})],
vec![index],
Expand Down
32 changes: 16 additions & 16 deletions src/constants/system_tables/pg_constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@ use hex_literal::hex;
use std::sync::Arc;
use uuid::Uuid;

pub const id: Uuid = Uuid::from_bytes(hex!("DB6AB6BB401B4071BE52763C0C550600"));
pub const name: &str = "pg_constraint";
pub const ID: Uuid = Uuid::from_bytes(hex!("DB6AB6BB401B4071BE52763C0C550600"));
pub const NAME: &str = "pg_constraint";

pub const column_id: &str = "id";
pub const column_class_id: &str = "class_id";
pub const column_index_id: &str = "index_id";
pub const column_name: &str = "name";
pub const column_type: &str = "type";
pub const COLUMN_ID: &str = "id";
pub const COLUMN_CLASS_ID: &str = "class_id";
pub const COLUMN_INDEX_ID: &str = "index_id";
pub const COLUMN_NAME: &str = "name";
pub const COLUMN_TYPE: &str = "type";

pub fn get_columns() -> Vec<Attribute> {
vec![
Attribute::new(
column_id.to_string(),
COLUMN_ID.to_string(),
BaseSqlTypesMapper::Uuid,
Nullable::NotNull,
None,
),
Attribute::new(
column_class_id.to_string(),
COLUMN_CLASS_ID.to_string(),
BaseSqlTypesMapper::Uuid,
Nullable::NotNull,
None,
),
Attribute::new(
column_index_id.to_string(),
COLUMN_INDEX_ID.to_string(),
BaseSqlTypesMapper::Uuid,
Nullable::NotNull,
None,
),
Attribute::new(
column_name.to_string(),
COLUMN_NAME.to_string(),
BaseSqlTypesMapper::Text,
Nullable::NotNull,
None,
),
Attribute::new(
column_type.to_string(),
COLUMN_TYPE.to_string(),
BaseSqlTypesMapper::Text,
Nullable::NotNull,
None,
Expand All @@ -54,7 +54,7 @@ pub fn get_columns() -> Vec<Attribute> {
pub fn get_index(attrs: &Vec<Attribute>) -> Arc<Index> {
Arc::new(Index {
id: Uuid::from_bytes(hex!("27182DE783AB42D8B5DD43BFC0154F0F")),
name: name.to_string() + "_name_index",
name: NAME.to_string() + "_name_index",
columns: Arc::new(SqlTypeDefinition::new(&[attrs[3].clone()])),
unique: true,
})
Expand All @@ -64,11 +64,11 @@ pub fn get_table() -> Arc<Table> {
let columns = get_columns();
let index = get_index(&columns);
Arc::new(Table::new(
id,
name.to_string(),
ID,
NAME.to_string(),
columns,
vec![Constraint::PrimaryKey(PrimaryKeyConstraint {
name: name.to_string() + "_primary_key",
name: NAME.to_string() + "_primary_key",
index: index.clone(),
})],
vec![index],
Expand Down
32 changes: 16 additions & 16 deletions src/constants/system_tables/pg_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@ use hex_literal::hex;
use std::sync::Arc;
use uuid::Uuid;

pub const id: Uuid = Uuid::from_bytes(hex!("3AB3B076A0EA46E186130F088D06FA02"));
pub const name: &str = "pg_index";
pub const ID: Uuid = Uuid::from_bytes(hex!("3AB3B076A0EA46E186130F088D06FA02"));
pub const NAME: &str = "pg_index";

pub const column_id: &str = "id";
pub const column_class_id: &str = "class_id";
pub const column_name: &str = "name";
pub const column_attributes: &str = "attributes";
pub const column_unique: &str = "unique";
pub const COLUMN_ID: &str = "id";
pub const COLUMN_CLASS_ID: &str = "class_id";
pub const COLUMN_NAME: &str = "name";
pub const COLUMN_ATTRIBUTES: &str = "attributes";
pub const COLUMN_UNIQUE: &str = "unique";

pub fn get_columns() -> Vec<Attribute> {
vec![
Attribute::new(
column_id.to_string(),
COLUMN_ID.to_string(),
BaseSqlTypesMapper::Uuid,
Nullable::NotNull,
None,
),
Attribute::new(
column_class_id.to_string(),
COLUMN_CLASS_ID.to_string(),
BaseSqlTypesMapper::Uuid,
Nullable::NotNull,
None,
),
Attribute::new(
column_name.to_string(),
COLUMN_NAME.to_string(),
BaseSqlTypesMapper::Text,
Nullable::NotNull,
None,
),
Attribute::new(
column_attributes.to_string(),
COLUMN_ATTRIBUTES.to_string(),
BaseSqlTypesMapper::Array(Arc::new(BaseSqlTypesMapper::Integer)),
Nullable::NotNull,
None,
),
Attribute::new(
column_unique.to_string(),
COLUMN_UNIQUE.to_string(),
BaseSqlTypesMapper::Bool,
Nullable::NotNull,
None,
Expand All @@ -54,7 +54,7 @@ pub fn get_columns() -> Vec<Attribute> {
pub fn get_index(attrs: &Vec<Attribute>) -> Arc<Index> {
Arc::new(Index {
id: Uuid::from_bytes(hex!("5F59466782874C568F1C0C09E99C9249")),
name: name.to_string() + "_name_index",
name: NAME.to_string() + "_name_index",
columns: Arc::new(SqlTypeDefinition::new(&[attrs[2].clone()])),
unique: true,
})
Expand All @@ -64,11 +64,11 @@ pub fn get_table() -> Arc<Table> {
let columns = get_columns();
let index = get_index(&columns);
Arc::new(Table::new(
id,
name.to_string(),
ID,
NAME.to_string(),
columns,
vec![Constraint::PrimaryKey(PrimaryKeyConstraint {
name: name.to_string() + "_primary_key",
name: NAME.to_string() + "_primary_key",
index: index.clone(),
})],
vec![index],
Expand Down
Loading

0 comments on commit 2370aaa

Please sign in to comment.