-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix invalid generated column names in conversion events (#327)
* Add valid_column_name macro * Update models using conversion_events * Add tests * Update project name in tests to call macros * Add new macro to unit tests * Fix invalid escape character * Fix page test by harmonizing event name * Fix jinja range error in test --------- Co-authored-by: Adam Ribaudo <adam.ribaudo@velir.com>
- Loading branch information
1 parent
3ef51b6
commit df85449
Showing
8 changed files
with
131 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% macro valid_column_name(column_name) %} | ||
{% set re = modules.re %} | ||
{% set pattern = '[^a-zA-Z0-9_]' %} | ||
{# a column name can't contain a non alphanumeric or _ character #} | ||
{% set cleaned_name = re.sub(pattern, '_', column_name|string) %} | ||
|
||
{% if re.match('^\\d', cleaned_name) %} | ||
{# a column name can't start by a number #} | ||
{{ return("_" ~ cleaned_name) }} | ||
{% else %} | ||
{{ return(cleaned_name) }} | ||
{% endif %} | ||
|
||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters