diff --git a/README.md b/README.md index 06a6328a..4247aa4a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,11 @@ [![ndc-hub](https://img.shields.io/badge/ndc--hub-sqlserver-blue.svg?style=flat)](https://hasura.io/connectors/sqlserver) [![License](https://img.shields.io/badge/license-Apache--2.0-purple.svg?style=flat)](LICENSE.txt) +> **Note:** ADO.NET is the supported connection string format for SQL Server for ndc-sqlserver in DDN. +> You can find the documentation for ADO.NET SQL Server connection strings [here](https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/connection-string-syntax#sqlclient-connection-strings). +> This is a change from Hasura version 2, where ODBC connection strings were supported. + + With this connector, Hasura allows you to instantly create a real-time GraphQL API on top of your data models in Microsoft SQL Server. This connector supports SQL Server's functionalities listed in the table below, allowing for efficient and scalable data operations. Additionally, users benefit from all the powerful features of Hasura’s Data @@ -77,6 +82,8 @@ default suggested port. #### Step 2.3: Provide the env vars for the connector +> **Note:** The `CONNECTION_URI` is the connection string of the SQL Server database. You can find the documentation for ADO.NET SQL Server connection string formats [here](https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/connection-string-syntax#sqlclient-connection-strings). + | Name | Description | Required | Default | |----------------|--------------------------------------------------|----------|---------| | CONNECTION_URI | The connection string of the SQL Server database | Yes | N/A | diff --git a/crates/configuration/src/version1.rs b/crates/configuration/src/version1.rs index 9d0f720c..a49b87fe 100644 --- a/crates/configuration/src/version1.rs +++ b/crates/configuration/src/version1.rs @@ -144,13 +144,26 @@ pub async fn create_state( }) } +// If the connection string is ODBC we want to throw an error. +fn is_odbc_connection_string(conn_str: &str) -> Result<(), bb8_tiberius::Error> { + if conn_str.contains("Driver=") || conn_str.contains("DSN=") { + Err(bb8_tiberius::Error::Tiberius(tiberius::error::Error::Io { + kind: std::io::ErrorKind::Other, + message: "ODBC connection strings are not supported. ADO.NET is the supported format.".into(), + })) + } else { + Ok(()) + } +} + /// Create a connection pool with default settings. async fn create_mssql_pool( configuration: &str, ) -> Result, bb8_tiberius::Error> { let connection_string = configuration.to_owned(); + // Lets check the string and error early if it is an ODBC connection string + is_odbc_connection_string(&connection_string)?; let config = tiberius::Config::from_ado_string(&connection_string)?; - let mgr = bb8_tiberius::ConnectionManager::new(config); bb8::Pool::builder().max_size(2).build(mgr).await