Skip to content

Commit c103963

Browse files
committed
fix more tests
1 parent d29fdb7 commit c103963

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

dbt/adapters/sqlserver/sql_server_column.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import ClassVar, Dict
1+
from typing import Any, ClassVar, Dict
22

33
from dbt.adapters.base import Column
44

@@ -11,3 +11,10 @@ class SQLServerColumn(Column):
1111
"INTEGER": "INT",
1212
"BOOLEAN": "BIT",
1313
}
14+
15+
@classmethod
16+
def string_type(cls, size: int) -> str:
17+
return f"varchar({size if size > 0 else 'MAX'})"
18+
19+
def literal(self, value: Any) -> str:
20+
return "cast('{}' as {})".format(value, self.data_type)

dbt/include/sqlserver/macros/adapters/columns.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,18 @@
5555
{%- endcall -%}
5656
5757
{% endmacro %}
58+
59+
60+
{% macro sqlserver__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}
61+
{% call statement('add_drop_columns') -%}
62+
{% if add_columns %}
63+
alter {{ relation.type }} {{ relation }}
64+
add {% for column in add_columns %}{{ column.name }} {{ column.data_type }}{{ ', ' if not loop.last }}{% endfor %};
65+
{% endif %}
66+
67+
{% if remove_columns %}
68+
alter {{ relation.type }} {{ relation }}
69+
drop column {% for column in remove_columns %}{{ column.name }}{{ ',' if not loop.last }}{% endfor %};
70+
{% endif %}
71+
{%- endcall -%}
72+
{% endmacro %}

0 commit comments

Comments
 (0)