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

fix: snapshots failing because of wrong mysql colum quoting #171

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Support dbt v1.5 ([#145](https://github.com/dbeatty10/dbt-mysql/issues/145))
- Support connecting via UNIX sockets ([#164](https://github.com/dbeatty10/dbt-mysql/issues/164))
- Support Black & MyPy pre-commit hooks ([#138](https://github.com/dbeatty10/dbt-mysql/issues/138))
- Support dbt snapshots if table DDL is evolving ([#171](https://github.com/dbeatty10/dbt-mysql/pull/171))

### Fixes
- Fix incremental composite keys ([#144](https://github.com/dbeatty10/dbt-mysql/issues/144))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{#
Add new columns to the table if applicable
#}

{% macro mariadb__create_columns(relation, columns) %}
{% for column in columns %}
{% call statement() %}
alter table {{ relation }} add column {{ column.quoted() }} {{ column.data_type }};
{% endcall %}
{% endfor %}
{% endmacro %}

{% macro mariadb__snapshot_string_as_time(timestamp) -%}
{%- set result = "str_to_date('" ~ timestamp ~ "', '%Y-%m-%d %T')" -%}
Expand Down
11 changes: 11 additions & 0 deletions dbt/include/mysql/macros/materializations/snapshot/snapshot.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{#
Add new columns to the table if applicable
#}

{% macro mysql__create_columns(relation, columns) %}
{% for column in columns %}
{% call statement() %}
alter table {{ relation }} add column {{ column.quoted() }} {{ column.data_type }};
{% endcall %}
{% endfor %}
{% endmacro %}

{% macro mysql__snapshot_string_as_time(timestamp) -%}
{%- set result = "str_to_date('" ~ timestamp ~ "', '%Y-%m-%d %T')" -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{#
Add new columns to the table if applicable
#}

{% macro mysql5__create_columns(relation, columns) %}
{% for column in columns %}
{% call statement() %}
alter table {{ relation }} add column {{ column.quoted() }} {{ column.data_type }};
{% endcall %}
{% endfor %}
{% endmacro %}

{% macro mysql5__snapshot_string_as_time(timestamp) -%}
{%- set result = "str_to_date('" ~ timestamp ~ "', '%Y-%m-%d %T')" -%}
Expand Down
Loading