dbt-msft / tsql-utils

dbt-utils for the dbt-msft family of packages
MIT License
26 stars 26 forks source link

BUG: dbt-utils drop_old_relations doesn't take into account model aliases #99

Open SFL-PR opened 11 months ago

SFL-PR commented 11 months ago

Hi all, first contribution to a project so please let me know if I've done anything wrong! 😄

Only a small change but a key one for the functionality of this macro, I think.

Currently, when collecting the models names to check presence in the target DB, the macro only looks at node.name. This means aliased models are not checked correctly and models still in use are dropped.

Simple suggested solution is to swap current_models.append(node.name) with current_models.append(node.name if node.config.alias == None else node.config.alias)