Skip to content

Commit

Permalink
fix: ofn not working if not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
datnguye committed Mar 30, 2024
1 parent ae36f30 commit e1cebc2
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 57 deletions.
72 changes: 36 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,38 @@ dbterd --version

- Play with CLIs:

<details>
<summary>Click me</summary>

```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
```
<details>
<summary>Click me</summary>

```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
```

</details>
</details>

- Play with Python API (whole ERD):

Expand Down Expand Up @@ -106,11 +106,7 @@ dbterd --version
</details>
## 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 ✨
Expand All @@ -123,3 +119,7 @@ Finally, super thanks to our *Contributors*:
<a href="https://github.com/datnguye/dbterd/graphs/contributors">
<img src="https://contrib.rocks/image?repo=datnguye/dbterd" />
</a>

</br>

[![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)
8 changes: 3 additions & 5 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions dbterd/adapters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion dbterd/adapters/targets/d2/d2_test_relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
2 changes: 1 addition & 1 deletion dbterd/adapters/targets/dbml/dbml_test_relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
readme = "README.md"
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/cli/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e1cebc2

Please sign in to comment.