Skip to content

Commit

Permalink
server/mssql: update odbc git reference to the commit which has error…
Browse files Browse the repository at this point in the history
… message fix

## 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](fpco/odbc#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 fpco/odbc@fc5b592
- Update the error messages in tests to conform with improved error messages from `odbc`

## Related issues
Closes hasura/graphql-engine-mono#3340

## Changelog

- ✅ `CHANGELOG.md` is updated with user-facing content relevant to this PR.

## Affected components
- ✅ server
- ✅ tests

PR-URL: hasura/graphql-engine-mono#3345
GitOrigin-RevId: a5694e8afb58b5ad71b9c9635a80dea1ec449f51
  • Loading branch information
rakeshkky authored and hasura-bot committed Jan 13, 2022
1 parent e30d51e commit 42a2787
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/src-test/Database/MSSQL/TransactionSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 42a2787

Please sign in to comment.