Skip to content

Commit

Permalink
add support and automated testing for case sensitive collations
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebruyn committed May 21, 2023
1 parent d2c9444 commit 7c16253
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/integration-tests-sqlserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
msodbc_version: ["17", "18"]
sqlserver_version: ["2017", "2019", "2022"]
collation: ["SQL_Latin1_General_CP1_CS_AS", "SQL_Latin1_General_CP1_CI_AS"]
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}:CI-${{ matrix.python_version }}-msodbc${{ matrix.msodbc_version }}
Expand All @@ -31,6 +32,7 @@ jobs:
DBT_TEST_USER_1: DBT_TEST_USER_1
DBT_TEST_USER_2: DBT_TEST_USER_2
DBT_TEST_USER_3: DBT_TEST_USER_3
COLLATION: ${{ matrix.collation }}
steps:
- uses: actions/checkout@v3

Expand Down
19 changes: 16 additions & 3 deletions devops/scripts/init_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@

for i in {1..50};
do
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "${SA_PASSWORD}" -d msdb -I -i init.sql
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "${SA_PASSWORD}" -d master -I -Q "CREATE DATABASE TestDB COLLATE ${COLLATION}"
if [ $? -eq 0 ]
then
echo "init.sql completed"
echo "database creation completed"
break
else
echo "not ready yet..."
echo "creating database..."
sleep 1
fi
done

for i in {1..50};
do
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "${SA_PASSWORD}" -d TestDB -I -i init.sql
if [ $? -eq 0 ]
then
echo "user creation completed"
break
else
echo "configuring users..."
sleep 1
fi
done
2 changes: 2 additions & 0 deletions devops/server.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ARG MSSQL_VERSION="2022"
FROM mcr.microsoft.com/mssql/server:${MSSQL_VERSION}-latest

ENV COLLATION="SQL_Latin1_General_CP1_CI_AS"

RUN mkdir -p /opt/init_scripts
WORKDIR /opt/init_scripts
COPY scripts/* /opt/init_scripts/
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
environment:
SA_PASSWORD: "L0calTesting!"
ACCEPT_EULA: "Y"
COLLATION: "SQL_Latin1_General_CP1_CS_AS"
env_file:
- test.env
ports:
Expand Down
4 changes: 2 additions & 2 deletions test.env.sample
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
SQLSERVER_TEST_DRIVER=ODBC Driver 18 for SQL Server
SQLSERVER_TEST_HOST=127.0.0.1
SQLSERVER_TEST_USER=sa
SQLSERVER_TEST_USER=SA
SQLSERVER_TEST_PASS=L0calTesting!
SQLSERVER_TEST_PORT=1433
SQLSERVER_TEST_DBNAME=msdb
SQLSERVER_TEST_DBNAME=TestDB
SQLSERVER_TEST_ENCRYPT=True
SQLSERVER_TEST_TRUST_CERT=True
DBT_TEST_USER_1=DBT_TEST_USER_1
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _profile_ci_sql_server():
"host": "sqlserver",
"user": "SA",
"pass": "5atyaNadella",
"database": "msdb",
"database": "TestDB",
"encrypt": True,
"trust_cert": True,
},
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/adapter/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def dbt_profile_target_update():
@staticmethod
def _verify_schema_owner(schema_name, owner, project):
get_schema_owner = f"""
select schema_owner from information_schema.schemata where schema_name = '{schema_name}'
select SCHEMA_OWNER from INFORMATION_SCHEMA.SCHEMATA where SCHEMA_NAME = '{schema_name}'
"""
result = project.run_sql(get_schema_owner, fetch="one")[0]
assert result == owner
Expand Down

0 comments on commit 7c16253

Please sign in to comment.