Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty strings in slugify macro #774

Closed

Conversation

atvaccaro
Copy link
Contributor

@atvaccaro atvaccaro commented Mar 28, 2023

resolves #773

This is a:

  • documentation update
  • 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

  • This code is associated with an Issue which has been triaged and accepted for development.
  • 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)
    • BigQuery
    • Postgres
    • Redshift
    • Snowflake
  • 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)
  • I have added tests & descriptions to my models (and macros if applicable)
  • I have added an entry to CHANGELOG.md

Copy link
Contributor

@joellabes joellabes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @atvaccaro! Looks good, one suggestion to make it a bit more robust

macros/jinja_helpers/slugify.sql Outdated Show resolved Hide resolved
@github-actions
Copy link

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 github-actions bot added the Stale label Oct 22, 2023
@github-actions github-actions bot removed the Stale label Oct 30, 2023
@atvaccaro
Copy link
Contributor Author

Can we merge this?

@dbeatty10 dbeatty10 added the bug Something isn't working label Apr 18, 2024
Copy link
Contributor

@dbeatty10 dbeatty10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


## Contributors:
@Harmuth94, [#768](https://github.com/dbt-labs/dbt-utils/issues/768)

@atvaccaro, [#773](https://github.com/dbt-labs/dbt-utils/issues/773)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@atvaccaro, [#773](https://github.com/dbt-labs/dbt-utils/issues/773)

@@ -11,10 +11,11 @@
# Unreleased
## Fixes
- get_relations_by_pattern for Databricks connection with Unity catalog #768 ([#768](https://github.com/dbt-labs/dbt-utils/issues/768), [#769](https://github.com/dbt-labs/dbt-utils/pull/769))
- Handle empty strings in slugify macro #773 ([#773](https://github.com/dbt-labs/dbt-utils/issues/773), [#774](https://github.com/dbt-labs/dbt-utils/pull/774))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a merge conflict that we need to resolve in CHANGELOG.md.

I wasn't able to push to the remote for some reason, so I'm going to try to remove these changes in order to resolve the merge conflict.

Suggested change
- Handle empty strings in slugify macro #773 ([#773](https://github.com/dbt-labs/dbt-utils/issues/773), [#774](https://github.com/dbt-labs/dbt-utils/pull/774))

@dbeatty10 dbeatty10 mentioned this pull request Jun 4, 2024
17 tasks
@dbeatty10
Copy link
Contributor

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 #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 dbeatty10 closed this Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dbt_utils 1.0 fails to handle empty strings in slugify
3 participants