Skip to content

Commit

Permalink
Support table names with double quotas
Browse files Browse the repository at this point in the history
  • Loading branch information
kurotych committed Sep 19, 2022
1 parent c1d3786 commit acc780c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlant"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "MIT"
repository = "https://github.com/kurotych/sqlant"
Expand Down
3 changes: 1 addition & 2 deletions src/plantuml_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct SColumn<'a> {
struct SEntity {
name: String,
pks: String, // Columns that contain PK
fks: String, // Columns that contain FK and doesn't containt PK
fks: String, // Columns that contain FK and don't containt PK
others: String, // Columns that don't contain both PK and FK
}

Expand Down Expand Up @@ -81,7 +81,6 @@ impl<'a> PlantUmlDefaultGenerator<'a> {
return !col.is_pk() && !col.is_fk();
}
panic!("Aaa! Something went wrong!");
// !col.is_pk()
})
.fold(String::new(), |acc, col| {
acc + &self
Expand Down
8 changes: 4 additions & 4 deletions src/psql_erd_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::sql_entities::{ForeignKey, SqlERData, SqlERDataLoader, Table, TableCo
use postgres::{Client, NoTls};

static GET_TABLES_LIST_QUERY: &'static str = r#"
SELECT table_name
SELECT trim(both '"' from table_name) as table_name
FROM information_schema.tables where table_schema = 'public'
"#;

Expand All @@ -30,8 +30,8 @@ ORDER BY relname;
// pg_get_constraintdef(oid) -- just for debugging purposes
/// https://www.postgresql.org/docs/current/catalog-pg-constraint.html
static GET_FOREIGN_KEYS_QUERY: &'static str = r#"
SELECT conrelid::regclass::name AS source_table_name,
confrelid::regclass::name AS target_table_name,
SELECT trim(both '"' from conrelid::regclass::name) AS source_table_name,
trim(both '"' from confrelid::regclass::name) AS target_table_name,
conname AS foreign_key_name,
conkey AS source_column_nums,
confkey AS target_columns_nums,
Expand All @@ -43,7 +43,7 @@ ORDER BY source_table_name;
"#;

static GET_PKS_QUERY: &'static str = r#"
SELECT conrelid::regclass::name AS table_name,
SELECT trim(both '"' from conrelid::regclass::name) as table_name,
conname AS primary_key_name,
conkey AS pk_columns_nums,
pg_get_constraintdef(oid) -- just for debugging purposes
Expand Down

0 comments on commit acc780c

Please sign in to comment.