dbt-utils icon indicating copy to clipboard operation
dbt-utils copied to clipboard

Handle empty strings in slugify macro

Open atvaccaro opened this issue 2 years ago • 2 comments

resolves #773

This is a:

  • [ ] documentation update
  • [x] bug fix with no breaking changes
  • [ ] new functionality
  • [ ] a breaking change

All pull requests from community contributors should target the main branch (default).

Description & motivation

As of the 1.0 release, slugify now prepends an underscore in the case of leading numbers. This throws an exception if the string is empty, but we can just return falsy strings without any modification.

Another option would be using a capture group or positive lookahead.

Checklist

  • [x] This code is associated with an Issue which has been triaged and accepted for development.
  • [x] I have verified that these changes work locally on the following warehouses (Note: it's okay if you do not have access to all warehouses, this helps us understand what has been covered)
    • [x] BigQuery
    • [ ] Postgres
    • [ ] Redshift
    • [ ] Snowflake
  • [x] I followed guidelines to ensure that my changes will work on "non-core" adapters by:
    • [ ] dispatching any new macro(s) so non-core adapters can also use them (e.g. the star() source)
    • [ ] using the limit_zero() macro in place of the literal string: limit 0
    • [ ] using dbt.type_* macros instead of explicit datatypes (e.g. dbt.type_timestamp() instead of TIMESTAMP
  • [ ] I have updated the README.md (if applicable)
  • [x] I have added tests & descriptions to my models (and macros if applicable)
  • [x] I have added an entry to CHANGELOG.md

atvaccaro avatar Mar 28 '23 15:03 atvaccaro

This PR has been marked as Stale because it has been open with no activity as of late. If you would like the PR to remain open, please comment on the PR or else it will be closed in 7 days.

github-actions[bot] avatar Oct 22 '23 01:10 github-actions[bot]

Can we merge this?

atvaccaro avatar Apr 01 '24 18:04 atvaccaro

In order to merge this, need to resolve a merge conflict first. I'm gonna try a thing or two to accomplish that.

I wasn't able to resolve the merge conflict in this PR, presumably because "Allow edits from maintainers" isn't enabled on this fork.

@atvaccaro I branched your original PR into https://github.com/dbt-labs/dbt-utils/pull/912 so that we can get your fixed merged. It's merged now, so I'm going to close this PR.

Thanks for opening the original bug report and submitting a fix! 🏆 It will be included in the next release of dbt-utils.

dbeatty10 avatar Jun 04 '24 23:06 dbeatty10