Skip to content

[BUG] generate-sources: database not recognized from CLI argument (nor config.yml) #511

@jim256

Description

@jim256

Describe the bug
When I explicitly pass a database name in generate-sources (e.g. dbt-coves generate-sources --database <my_db_name>), that DB name isn't used / recognized in the {{database}} variable in config.yml.

To Reproduce
Steps to reproduce the behaviour:

  1. set up sources_destination using the {{database}} variable in the path
    e.g. sources_destination: "models/staging/{{database}}/{{database}}__{{schema}}/_{{schema}}__sources.yml"
  2. run dbt-coves generate-sources --database <my_db_name>

Expected behaviour
I expect my database name to be in the folder name of the generated sources.

Instead, the path dbt-coves creates is equivalent to models/staging/__{{schema}}/_{{schema}}__sources.yml

Desktop (please complete the following information):

  • OS: macOS 15.3.2
  • Version 1.9.0

Additional context
I've tried this with and without commenting the database variable at the top of sources. I've noticed this variable is also ignored. I think it'd be more intuitive to the user if {{database}} could come from either the CLI or config.yml, though for me personally, I just care about it coming from the CLI.
I also tried these variables:

  1. {{ source_database }} (blank)
  2. {{ relation.database }} (blank)
  3. {{node.fqn[-3]}} (error: ❌ 'node' is undefined)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriaged: noHasn't been approved for future implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions