tedivm / paracelsus

Visualize SQLAlchemy Databases using Mermaid or Dot Diagrams.
https://pypi.org/project/paracelsus/
MIT License
94 stars 10 forks source link

Add column_sort option #18

Closed selfdanielj closed 5 months ago

selfdanielj commented 5 months ago

Resolves #14

Allows users to specify they want to preserve the order of columns that exists in their models when using paracelsus to produce diagrams:

Did not add pyproject.toml support for this option since there is not a clear precedent in this project for supporting a cli option with a default value and a pyproject-specified option.

tedivm commented 5 months ago

Looks like tests are failing for python 3.10 (which is still supported at the moment). Formatting is also failing but that should be a simple make chores call.

tedivm commented 5 months ago

For pyproject support I would pull the settings into the top of the module, and then do something like:

    column_sort: Annotated[
        ColumnSorts,
        typer.Option(
            help="Specifies the method of sorting columns in diagrams.",
        ),
    ] = pyproject_settings.get("column_sort", ColumnSorts.key_based),

If you use the pyproject settings to override the default you get the best of all worlds, as it will use your supplied default UNLESS their pyproject is set UNLESS the cli flag is used. It also means the help command will tell users what the default for their project is if their pyproject.toml overrides the real default.