Skip to content

Commit 06f0593

Browse files
authored
Update docs to reflect ADO.NET connection string (#167)
<!-- The PR description should answer 2 (maybe 3) important questions: --> ### What In Hasura v2 we supported ODBC connection string for sqlserver, but in DDN we support ADO.NET connection strings. <!-- What is this PR trying to accomplish (and why, if it's not obvious)? --> ### How - Update docs to reflect the connection string format supported - Try to detect ODBC format and throw a useful error when initializing the connection <!-- How is it trying to accomplish it (what are the implementation steps)? -->
1 parent 9b81c65 commit 06f0593

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
[![ndc-hub](https://img.shields.io/badge/ndc--hub-sqlserver-blue.svg?style=flat)](https://hasura.io/connectors/sqlserver)
55
[![License](https://img.shields.io/badge/license-Apache--2.0-purple.svg?style=flat)](LICENSE.txt)
66

7+
> **Note:** ADO.NET is the supported connection string format for SQL Server for ndc-sqlserver in DDN.
8+
> 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).
9+
> This is a change from Hasura version 2, where ODBC connection strings were supported.
10+
11+
712
With this connector, Hasura allows you to instantly create a real-time GraphQL API on top of your data models in
813
Microsoft SQL Server. This connector supports SQL Server's functionalities listed in the table below, allowing for
914
efficient and scalable data operations. Additionally, users benefit from all the powerful features of Hasura’s Data
@@ -77,6 +82,8 @@ default suggested port.
7782

7883
#### Step 2.3: Provide the env vars for the connector
7984

85+
> **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).
86+
8087
| Name | Description | Required | Default |
8188
|----------------|--------------------------------------------------|----------|---------|
8289
| CONNECTION_URI | The connection string of the SQL Server database | Yes | N/A |

crates/configuration/src/version1.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,27 @@ pub async fn create_state(
144144
})
145145
}
146146

147+
// If the connection string is ODBC we want to throw an error.
148+
fn is_odbc_connection_string(conn_str: &str) -> Result<(), bb8_tiberius::Error> {
149+
if conn_str.contains("Driver=") || conn_str.contains("DSN=") {
150+
Err(bb8_tiberius::Error::Tiberius(tiberius::error::Error::Io {
151+
kind: std::io::ErrorKind::Other,
152+
message: "ODBC connection strings are not supported. ADO.NET is the supported format."
153+
.into(),
154+
}))
155+
} else {
156+
Ok(())
157+
}
158+
}
159+
147160
/// Create a connection pool with default settings.
148161
async fn create_mssql_pool(
149162
configuration: &str,
150163
) -> Result<bb8::Pool<bb8_tiberius::ConnectionManager>, bb8_tiberius::Error> {
151164
let connection_string = configuration.to_owned();
165+
// Lets check the string and error early if it is an ODBC connection string
166+
is_odbc_connection_string(&connection_string)?;
152167
let config = tiberius::Config::from_ado_string(&connection_string)?;
153-
154168
let mgr = bb8_tiberius::ConnectionManager::new(config);
155169

156170
bb8::Pool::builder().max_size(2).build(mgr).await

0 commit comments

Comments
 (0)