From 42a2787290fa3b8765580ab388fc40a334daf5ca Mon Sep 17 00:00:00 2001 From: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com> Date: Thu, 13 Jan 2022 16:43:52 +0530 Subject: [PATCH] server/mssql: update odbc git reference to the commit which has error message fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description I come across a flaky test due to inconsistent error messages from the odbc lib we use for MSSQL database interactions. ``` cabal new-run -- test:graphql-engine-tests mssql Up to date Database.MSSQL.TransactionSpec runTx runs command in a transaction commits a successful transaction, returning a single field commits a successful transaction, returning multiple fields an unsuccesful transaction, expecting Int a successfull query expecting multiple rows an unsuccesful transaction; expecting single row displays the SQL Server error on an unsuccessful transaction FAILED [1] rolls back an unsuccessful transaction Failures: src-test/Database/MSSQL/TransactionSpec.hs:60:15: 1) Database.MSSQL.TransactionSpec.runTx displays the SQL Server error on an unsuccessful transaction expected: UnsuccessfulReturnCode "odbc_SQLExecDirectW" (-1) "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type.[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type." but got: UnsuccessfulReturnCode "odbc_SQLExecDirectW" (-1) "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type.[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type.\DEL" To rerun use: --match "/Database.MSSQL.TransactionSpec/runTx/displays the SQL Server error on an unsuccessful transaction/" Randomized with seed 1101559172 Finished in 0.2140 seconds 8 examples, 1 failure ``` From above, we got a error message with `\DEL` appended. It is also driving the tests to fail in the CI on random PRs. We brought this into notice of "fpco", the authors of the library and they got us a [quick fix](https://github.com/fpco/odbc/pull/43), which also improves the errors by removing the redundancy of the error message. In this PR - We update the `odbc` library git reference to https://github.com/fpco/odbc/commit/fc5b592a607d932e5fc96c0f74c0df7c3e910883 - Update the error messages in tests to conform with improved error messages from `odbc` ## Related issues Closes https://github.com/hasura/graphql-engine-mono/issues/3340 ## Changelog - ✅ `CHANGELOG.md` is updated with user-facing content relevant to this PR. ## Affected components - ✅ server - ✅ tests PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3345 GitOrigin-RevId: a5694e8afb58b5ad71b9c9635a80dea1ec449f51 --- CHANGELOG.md | 1 + cabal.project | 2 +- server/src-test/Database/MSSQL/TransactionSpec.hs | 2 +- .../queries/v2/mssql/run_sql/create_author_table_fail.yaml | 3 +-- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2707b7d3250..0a3b92a949a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Next release (Add highlights/major features below) +- server: improve error messages in MSSQL database query exceptions - server: in mssql transactions, rollback only if the transaction is active - server: add request and response bodies to OpenAPI specification of REST endpoints - server: implement upsert mutations for MS SQL Server (close #7864) diff --git a/cabal.project b/cabal.project index cce2bc99a3e..82c7d54904e 100644 --- a/cabal.project +++ b/cabal.project @@ -70,7 +70,7 @@ source-repository-package source-repository-package type: git location: https://github.com/fpco/odbc.git - tag: 7c0cea45d0b779419eb16177407c4ee9e7ba4c6f + tag: fc5b592a607d932e5fc96c0f74c0df7c3e910883 package odbc ghc-options: -Wwarn diff --git a/server/src-test/Database/MSSQL/TransactionSpec.hs b/server/src-test/Database/MSSQL/TransactionSpec.hs index b861429f885..42e7c66a08f 100644 --- a/server/src-test/Database/MSSQL/TransactionSpec.hs +++ b/server/src-test/Database/MSSQL/TransactionSpec.hs @@ -119,7 +119,7 @@ runInConn connString query = invalidSyntaxError :: String invalidSyntaxError = - "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type.[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type." + "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type." unexpectedMSSQLInternalError :: String unexpectedMSSQLInternalError = diff --git a/server/tests-py/queries/v2/mssql/run_sql/create_author_table_fail.yaml b/server/tests-py/queries/v2/mssql/run_sql/create_author_table_fail.yaml index c3fb9b86b77..5950518a00e 100644 --- a/server/tests-py/queries/v2/mssql/run_sql/create_author_table_fail.yaml +++ b/server/tests-py/queries/v2/mssql/run_sql/create_author_table_fail.yaml @@ -14,8 +14,7 @@ response: - odbc_SQLExecDirectW - -1 - "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]There is already an object\ - \ named 'author' in the database.[Microsoft][ODBC Driver 17 for SQL Server][SQL\ - \ Server]There is already an object named 'author' in the database." + \ named 'author' in the database." path: $ error: sql query exception code: mssql-error