From 53c71aced75ca5b98fd670d9fb7a36345fd5d4f5 Mon Sep 17 00:00:00 2001 From: Valerii Mironchenko Date: Mon, 22 Jan 2024 10:56:58 +0200 Subject: [PATCH 1/3] Add relationships path to PostgresqlPathsModel --- oddrn_generator/path_models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/oddrn_generator/path_models.py b/oddrn_generator/path_models.py index dbff004..d18f7e0 100644 --- a/oddrn_generator/path_models.py +++ b/oddrn_generator/path_models.py @@ -58,6 +58,7 @@ class PostgresqlPathsModel(BasePathsModel): views: Optional[str] tables_columns: Optional[str] = Field(alias="columns") views_columns: Optional[str] = Field(alias="columns") + relationships: Optional[str] class Config: dependencies_map = { @@ -67,6 +68,7 @@ class Config: "views": ("databases", "schemas", "views"), "tables_columns": ("databases", "schemas", "tables", "tables_columns"), "views_columns": ("databases", "schemas", "views", "views_columns"), + "relationships": ("databases", "schemas", "tables", "relationships"), } data_source_path = "databases" From ac16376da3e3919b42a1a63e6b96e1ade48b510d Mon Sep 17 00:00:00 2001 From: Valerii Mironchenko Date: Mon, 22 Jan 2024 10:58:30 +0200 Subject: [PATCH 2/3] Update README with example of relationships path. Fix previous mistakes. --- README.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 83d8f67..ddaa59c 100644 --- a/README.md +++ b/README.md @@ -94,28 +94,31 @@ oddrn_gen = PostgresqlGenerator( oddrn_gen.base_oddrn # //postgresql/host/my.host.com:5432 oddrn_gen.available_paths -# ('schemas', 'databases', 'tables', 'columns') +# ('databases', 'schemas', 'tables', 'views', 'tables_columns', 'views_columns', 'relationships') oddrn_gen.get_data_source_oddrn() -# //postgresql/host/my.host.com:5432/schemas/schema_name/databases/database_name +# //postgresql/host/my.host.com:5432/databases/database_name oddrn_gen.get_oddrn_by_path("schemas") -# //postgresql/host/my.host.com:5432/schemas/schema_name +# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name oddrn_gen.get_oddrn_by_path("databases") -# //postgresql/host/my.host.com:5432/schemas/schema_name/databases/database_name +# //postgresql/host/my.host.com:5432/databases/database_name oddrn_gen.get_oddrn_by_path("tables") -# //postgresql/host/my.host.com:5432/schemas/schema_name/databases/database_name/tables/table_name +# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/table_name # you can set or change path: -oddrn_gen.set_oddrn_paths(tables='another_table_name', columns='new_column_name') -oddrn_gen.get_oddrn_by_path("columns") -# //postgresql/host/my.host.com:5432/schemas/schema_name/databases/database_name/tables/another_table_name/columns/new_column_name +oddrn_gen.set_oddrn_paths(tables="another_table_name", tables_columns="new_column_name") +oddrn_gen.get_oddrn_by_path("tables_columns") +# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/columns/new_column_name + +oddrn_gen.set_oddrn_paths(relationships="references_table_2_with_constraint_fk") +# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/relationships/references_table_2_with_constraint_fk # you can get path wih new values: -oddrn_gen.get_oddrn_by_path("columns", new_value="another_new_column_name") -# //postgresql/host/my.host.com:5432/schemas/schema_name/databases/database_name/tables/another_table_name/columns/another_new_column_name +oddrn_gen.get_oddrn_by_path("tables_columns", new_value="another_new_column_name") +# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/columns/another_new_column_name # glue @@ -160,9 +163,9 @@ from oddrn_generator import PostgresqlGenerator oddrn_gen = PostgresqlGenerator( host_settings='my.host.com:5432', schemas='schema_name', databases='database_name', - columns='column_without_table' + tables_columns='column_without_table' ) -# WrongPathOrderException: 'columns' can not be without 'tables' attribute +# WrongPathOrderException: 'tables_columns' can not be without 'tables' attribute ``` * EmptyPathValueException - raises when trying to get a path that is not set up @@ -201,5 +204,5 @@ poetry install poetry shell # Run tests -python run pytest +pytest tests/ ``` From 0b611be872db5adb51f3e9e42eef3a525fbbb834 Mon Sep 17 00:00:00 2001 From: Valerii Mironchenko Date: Mon, 22 Jan 2024 10:58:58 +0200 Subject: [PATCH 3/3] Update tests --- tests/params.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/params.py b/tests/params.py index f5332c4..f2a2574 100644 --- a/tests/params.py +++ b/tests/params.py @@ -38,6 +38,7 @@ "views": "some_view", "tables_columns": "some_table_column", "views_columns": "some_view_column", + "relationships": "some_relationship", }, "aliases": { "tables_columns": "columns",