diff --git a/README.md b/README.md index eee7fea..977fb37 100644 --- a/README.md +++ b/README.md @@ -26,38 +26,38 @@ dbterd --version - Play with CLIs: -
- Click me - - ```bash - # select all models in dbt_resto - dbterd run -ad samples/dbtresto - # select all models in dbt_resto, Select multiple dbt resources - dbterd run -ad samples/dbtresto -rt model -rt source - # select only models in dbt_resto excluding staging - dbterd run -ad samples/dbtresto -s model.dbt_resto -ns model.dbt_resto.staging - # select only models in schema name mart excluding staging - dbterd run -ad samples/dbtresto -s schema:mart -ns model.dbt_resto.staging - # select only models in schema full name dbt.mart excluding staging - dbterd run -ad samples/dbtresto -s schema:dbt.mart -ns model.dbt_resto.staging - - # other samples - dbterd run -ad samples/fivetranlog - dbterd run -ad samples/fivetranlog -rt model -rt source - - dbterd run -ad samples/facebookad - dbterd run -ad samples/facebookad -rt model -rt source - - dbterd run -ad samples/shopify -s wildcard:*shopify.shopify__* - dbterd run -ad samples/shopify -rt model -rt source - - dbterd run -ad samples/dbt-constraints -a "test_relationship:(name:foreign_key|c_from:fk_column_name|c_to:pk_column_name)" - - # your own sample without commiting to repo - dbterd run -ad samples/local -rt model -rt source - ``` +
+ Click me + + ```bash + # select all models in dbt_resto + dbterd run -ad samples/dbtresto + # select all models in dbt_resto, Select multiple dbt resources + dbterd run -ad samples/dbtresto -rt model -rt source + # select only models in dbt_resto excluding staging + dbterd run -ad samples/dbtresto -s model.dbt_resto -ns model.dbt_resto.staging + # select only models in schema name mart excluding staging + dbterd run -ad samples/dbtresto -s schema:mart -ns model.dbt_resto.staging + # select only models in schema full name dbt.mart excluding staging + dbterd run -ad samples/dbtresto -s schema:dbt.mart -ns model.dbt_resto.staging + + # other samples + dbterd run -ad samples/fivetranlog + dbterd run -ad samples/fivetranlog -rt model -rt source + + dbterd run -ad samples/facebookad + dbterd run -ad samples/facebookad -rt model -rt source + + dbterd run -ad samples/shopify -s wildcard:*shopify.shopify__* + dbterd run -ad samples/shopify -rt model -rt source + + dbterd run -ad samples/dbt-constraints -a "test_relationship:(name:foreign_key|c_from:fk_column_name|c_to:pk_column_name)" + + # your own sample without commiting to repo + dbterd run -ad samples/local -rt model -rt source + ``` -
+
- Play with Python API (whole ERD): @@ -106,11 +106,7 @@ dbterd --version -## Quick DEMO - -Check [Quick Demo](https://dbterd.datnguyen.de/latest/nav/guide/targets/generate-dbml.html) out! And, following is the sample result using `dbdocs`: - -![screencapture-dbdocs-io-datnguye-poc-2023-02-25-10_29_32.png](https://raw.githubusercontent.com/datnguye/dbterd/main/assets/images/screencapture-dbdocs-io-datnguye-poc-2023-02-25-10_29_32.png) +🏃Check out the [Quick Demo](https://dbterd.datnguyen.de/latest/nav/guide/targets/generate-dbml.html) with DBML! ## Contributing ✨ @@ -123,3 +119,7 @@ Finally, super thanks to our *Contributors*: + +
+ +[![buy me a coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?logo=buy-me-a-coffee&logoColor=white&labelColor=ff813f&style=for-the-badge)](https://www.buymeacoffee.com/datnguye) diff --git a/SECURITY.md b/SECURITY.md index 2b90d6d..4967adb 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,11 +4,9 @@ | Version | Supported | Until When? | | ------- | ------------------ | ------------------ | -| 1.9.x | :white_check_mark: | | -| 1.8.x | :white_check_mark: | | -| 1.7.x | :warning: | End of Feb 2024 | -| 1.6.x | :warning: | End of Jan 2024 | -| < 1.6 | :x: | End of Life | +| >=1.13 | :white_check_mark: | | +| >1.10, <=1.12 | :warning: | End of Jun 2024 | +| <=1.10 | :x: | End of Support | ## Reporting a Vulnerability diff --git a/dbterd/adapters/base.py b/dbterd/adapters/base.py index 766694a..b44e99e 100644 --- a/dbterd/adapters/base.py +++ b/dbterd/adapters/base.py @@ -54,9 +54,9 @@ def evaluate_kwargs(self, **kwargs) -> dict: select = list(kwargs.get("select")) or [] exclude = list(kwargs.get("exclude")) or [] - unsupported, rule = has_unsupported_rule( - rules=select.extend(exclude) if exclude else select - ) + select.extend(exclude) + + unsupported, rule = has_unsupported_rule(rules=select) if unsupported: message = f"Unsupported Selection found: {rule}" logger.error(message) diff --git a/dbterd/adapters/targets/d2/d2_test_relationship.py b/dbterd/adapters/targets/d2/d2_test_relationship.py index c918f3a..3d070c8 100644 --- a/dbterd/adapters/targets/d2/d2_test_relationship.py +++ b/dbterd/adapters/targets/d2/d2_test_relationship.py @@ -14,7 +14,7 @@ def run(manifest: Manifest, catalog: Catalog, **kwargs) -> Tuple[str, str]: Returns: Tuple(str, str): File name and the D2 content """ - output_file_name = kwargs.get("output_file_name", "output.d2") + output_file_name = kwargs.get("output_file_name") or "output.d2" return (output_file_name, parse(manifest, catalog, **kwargs)) diff --git a/dbterd/adapters/targets/dbml/dbml_test_relationship.py b/dbterd/adapters/targets/dbml/dbml_test_relationship.py index 2acdf3c..4aefa40 100644 --- a/dbterd/adapters/targets/dbml/dbml_test_relationship.py +++ b/dbterd/adapters/targets/dbml/dbml_test_relationship.py @@ -15,7 +15,7 @@ def run(manifest: Manifest, catalog: Catalog, **kwargs) -> Tuple[str, str]: Returns: Tuple(str, str): File name and the DBML content """ - output_file_name = kwargs.get("output_file_name", "output.dbml") + output_file_name = kwargs.get("output_file_name") or "output.dbml" return (output_file_name, parse(manifest, catalog, **kwargs)) diff --git a/dbterd/adapters/targets/graphviz/graphviz_test_relationship.py b/dbterd/adapters/targets/graphviz/graphviz_test_relationship.py index d3aa458..da47552 100644 --- a/dbterd/adapters/targets/graphviz/graphviz_test_relationship.py +++ b/dbterd/adapters/targets/graphviz/graphviz_test_relationship.py @@ -14,7 +14,7 @@ def run(manifest: Manifest, catalog: Catalog, **kwargs) -> Tuple[str, str]: Returns: Tuple(str, str): File name and the GraphViz content """ - output_file_name = kwargs.get("output_file_name", "output.graphviz") + output_file_name = kwargs.get("output_file_name") or "output.graphviz" return (output_file_name, parse(manifest, catalog, **kwargs)) diff --git a/dbterd/adapters/targets/mermaid/mermaid_test_relationship.py b/dbterd/adapters/targets/mermaid/mermaid_test_relationship.py index a38609d..285821b 100644 --- a/dbterd/adapters/targets/mermaid/mermaid_test_relationship.py +++ b/dbterd/adapters/targets/mermaid/mermaid_test_relationship.py @@ -15,7 +15,7 @@ def run(manifest: Manifest, catalog: Catalog, **kwargs) -> Tuple[str, str]: Returns: Tuple(str, str): File name and the Mermaid content """ - output_file_name = kwargs.get("output_file_name", "output.md") + output_file_name = kwargs.get("output_file_name") or "output.md" return (output_file_name, parse(manifest, catalog, **kwargs)) diff --git a/dbterd/adapters/targets/plantuml/plantuml_test_relationship.py b/dbterd/adapters/targets/plantuml/plantuml_test_relationship.py index ccd6289..549f432 100644 --- a/dbterd/adapters/targets/plantuml/plantuml_test_relationship.py +++ b/dbterd/adapters/targets/plantuml/plantuml_test_relationship.py @@ -14,7 +14,7 @@ def run(manifest: Manifest, catalog: Catalog, **kwargs) -> Tuple[str, str]: Returns: Tuple(str, str): File name and the PlantUML content """ - output_file_name = kwargs.get("output_file_name", "output.plantuml") + output_file_name = kwargs.get("output_file_name") or "output.plantuml" return (output_file_name, parse(manifest, catalog, **kwargs)) diff --git a/poetry.lock b/poetry.lock index f2834ec..13acdb1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2143,4 +2143,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "33e6d114179a7a333896be95e2c5e90eb1cd9a261e2460c736f3a337ac0bdaea" +content-hash = "2adc89256eaa55ed925059fff17a7f421b4e143be886e732cfc89e321021fbf8" diff --git a/pyproject.toml b/pyproject.toml index 6d815cf..9cf2b38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "dbterd" version = "1.0.0" -description = "CLI to generate ERD Diagram file from dbt artifact files" +description = "Generate the ERD-as-a-code from dbt artifacts" authors = ["Dat Nguyen "] license = "MIT" readme = "README.md" @@ -33,7 +33,8 @@ requests = "^2.31.0" dbt-artifacts-parser = "^0" [tool.poetry.group.dev.dependencies] -dbt-postgres = "^1.5" +dbt-core = "^1.7.11" +dbt-postgres = "^1.7.11" pytest = "^6.2.5" pytest-sugar = "^0.9.6" black = "^22.10.0" diff --git a/tests/unit/cli/test_runner.py b/tests/unit/cli/test_runner.py index d80cc6c..a89e891 100644 --- a/tests/unit/cli/test_runner.py +++ b/tests/unit/cli/test_runner.py @@ -72,11 +72,11 @@ def test_invoke_run_with_invalid_strategy(self, dbterd: dbterdRunner) -> None: @pytest.mark.parametrize( "target, output", [ - ("dbml", None), - ("mermaid", None), - ("plantuml", None), - ("graphviz", None), - ("d2", None), + ("dbml", "output.dbml"), + ("mermaid", "output.md"), + ("plantuml", "output.plantuml"), + ("graphviz", "output.graphviz"), + ("d2", "output.d2"), ], ) def test_invoke_run_ok(self, target, output, dbterd: dbterdRunner) -> None: