Skip to content

Commit b5ac6c1

Browse files
authored
Merge pull request #391 from dbt-msft/cs-collation-support
add support and automated testing for case sensitive collations
2 parents d2c9444 + 7c16253 commit b5ac6c1

File tree

7 files changed

+25
-7
lines changed

7 files changed

+25
-7
lines changed

.github/workflows/integration-tests-sqlserver.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
2020
msodbc_version: ["17", "18"]
2121
sqlserver_version: ["2017", "2019", "2022"]
22+
collation: ["SQL_Latin1_General_CP1_CS_AS", "SQL_Latin1_General_CP1_CI_AS"]
2223
runs-on: ubuntu-latest
2324
container:
2425
image: ghcr.io/${{ github.repository }}:CI-${{ matrix.python_version }}-msodbc${{ matrix.msodbc_version }}
@@ -31,6 +32,7 @@ jobs:
3132
DBT_TEST_USER_1: DBT_TEST_USER_1
3233
DBT_TEST_USER_2: DBT_TEST_USER_2
3334
DBT_TEST_USER_3: DBT_TEST_USER_3
35+
COLLATION: ${{ matrix.collation }}
3436
steps:
3537
- uses: actions/checkout@v3
3638

devops/scripts/init_db.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22

33
for i in {1..50};
44
do
5-
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "${SA_PASSWORD}" -d msdb -I -i init.sql
5+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "${SA_PASSWORD}" -d master -I -Q "CREATE DATABASE TestDB COLLATE ${COLLATION}"
66
if [ $? -eq 0 ]
77
then
8-
echo "init.sql completed"
8+
echo "database creation completed"
99
break
1010
else
11-
echo "not ready yet..."
11+
echo "creating database..."
12+
sleep 1
13+
fi
14+
done
15+
16+
for i in {1..50};
17+
do
18+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "${SA_PASSWORD}" -d TestDB -I -i init.sql
19+
if [ $? -eq 0 ]
20+
then
21+
echo "user creation completed"
22+
break
23+
else
24+
echo "configuring users..."
1225
sleep 1
1326
fi
1427
done

devops/server.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
ARG MSSQL_VERSION="2022"
22
FROM mcr.microsoft.com/mssql/server:${MSSQL_VERSION}-latest
33

4+
ENV COLLATION="SQL_Latin1_General_CP1_CI_AS"
5+
46
RUN mkdir -p /opt/init_scripts
57
WORKDIR /opt/init_scripts
68
COPY scripts/* /opt/init_scripts/

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
environment:
99
SA_PASSWORD: "L0calTesting!"
1010
ACCEPT_EULA: "Y"
11+
COLLATION: "SQL_Latin1_General_CP1_CS_AS"
1112
env_file:
1213
- test.env
1314
ports:

test.env.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
SQLSERVER_TEST_DRIVER=ODBC Driver 18 for SQL Server
22
SQLSERVER_TEST_HOST=127.0.0.1
3-
SQLSERVER_TEST_USER=sa
3+
SQLSERVER_TEST_USER=SA
44
SQLSERVER_TEST_PASS=L0calTesting!
55
SQLSERVER_TEST_PORT=1433
6-
SQLSERVER_TEST_DBNAME=msdb
6+
SQLSERVER_TEST_DBNAME=TestDB
77
SQLSERVER_TEST_ENCRYPT=True
88
SQLSERVER_TEST_TRUST_CERT=True
99
DBT_TEST_USER_1=DBT_TEST_USER_1

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _profile_ci_sql_server():
113113
"host": "sqlserver",
114114
"user": "SA",
115115
"pass": "5atyaNadella",
116-
"database": "msdb",
116+
"database": "TestDB",
117117
"encrypt": True,
118118
"trust_cert": True,
119119
},

tests/functional/adapter/test_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def dbt_profile_target_update():
2222
@staticmethod
2323
def _verify_schema_owner(schema_name, owner, project):
2424
get_schema_owner = f"""
25-
select schema_owner from information_schema.schemata where schema_name = '{schema_name}'
25+
select SCHEMA_OWNER from INFORMATION_SCHEMA.SCHEMATA where SCHEMA_NAME = '{schema_name}'
2626
"""
2727
result = project.run_sql(get_schema_owner, fetch="one")[0]
2828
assert result == owner

0 commit comments

Comments
 (0)