Skip to content

Commit 31adace

Browse files
Source-MSSQL : special character support in dbname #14824 #15186 (#15268)
* dot in db name * doc update doc update * auto-bump connector version [ci skip] Co-authored-by: Octavia Squidington III <[email protected]>
1 parent 6b5e4fb commit 31adace

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@
564564
- name: Microsoft SQL Server (MSSQL)
565565
sourceDefinitionId: b5ea17b1-f170-46dc-bc31-cc744ca984c1
566566
dockerRepository: airbyte/source-mssql
567-
dockerImageTag: 0.4.12
567+
dockerImageTag: 0.4.13
568568
documentationUrl: https://docs.airbyte.io/integrations/sources/mssql
569569
icon: mssql.svg
570570
sourceType: database

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5003,7 +5003,7 @@
50035003
supportsNormalization: false
50045004
supportsDBT: false
50055005
supported_destination_sync_modes: []
5006-
- dockerImage: "airbyte/source-mssql:0.4.12"
5006+
- dockerImage: "airbyte/source-mssql:0.4.13"
50075007
spec:
50085008
documentationUrl: "https://docs.airbyte.io/integrations/destinations/mssql"
50095009
connectionSpecification:

airbyte-integrations/connectors/source-mssql/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ ENV APPLICATION source-mssql
1616

1717
COPY --from=build /airbyte /airbyte
1818

19-
LABEL io.airbyte.version=0.4.12
19+
LABEL io.airbyte.version=0.4.13
2020
LABEL io.airbyte.name=airbyte/source-mssql

airbyte-integrations/connectors/source-mssql/src/main/java/io/airbyte/integrations/source/mssql/MssqlSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ protected void assertCdcSchemaQueryable(final JsonNode config, final JdbcDatabas
284284

285285
// Azure SQL does not support USE clause
286286
final String sql =
287-
isAzureSQL ? "SELECT * FROM cdc.change_tables" : "USE " + config.get(JdbcUtils.DATABASE_KEY).asText() + "; SELECT * FROM cdc.change_tables";
287+
isAzureSQL ? "SELECT * FROM cdc.change_tables" : "USE [" + config.get(JdbcUtils.DATABASE_KEY).asText() + "]; SELECT * FROM cdc.change_tables";
288288
final PreparedStatement ps = connection.prepareStatement(sql);
289289
LOGGER.info(String.format(
290290
"Checking user '%s' can query the cdc schema and that we have at least 1 cdc enabled table using the query: '%s'",

airbyte-integrations/connectors/source-mssql/src/test/java/io/airbyte/integrations/source/mssql/CdcMssqlSourceTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class CdcMssqlSourceTest extends CdcSourceTest {
5858
private MSSQLServerContainer<?> container;
5959

6060
private String dbName;
61+
private String dbNamewithDot;
6162
private Database database;
6263
private JdbcDatabase testJdbcDatabase;
6364
private MssqlSource source;
@@ -81,6 +82,7 @@ private void init() {
8182
container.start();
8283

8384
dbName = Strings.addRandomSuffix("db", "_", 10).toLowerCase();
85+
dbNamewithDot = Strings.addRandomSuffix("db", ".", 10).toLowerCase();
8486
source = new MssqlSource();
8587

8688
final JsonNode replicationConfig = Jsons.jsonNode(Map.of(
@@ -120,6 +122,7 @@ private void init() {
120122
testJdbcDatabase = new DefaultJdbcDatabase(testDataSource);
121123

122124
executeQuery("CREATE DATABASE " + dbName + ";");
125+
executeQuery("CREATE DATABASE [" + dbNamewithDot + "];");
123126
switchSnapshotIsolation(true, dbName);
124127
}
125128

@@ -158,7 +161,7 @@ public String createSchemaQuery(final String schemaName) {
158161

159162
private void switchCdcOnDatabase(final Boolean enable, final String db) {
160163
final String storedProc = enable ? "sys.sp_cdc_enable_db" : "sys.sp_cdc_disable_db";
161-
executeQuery("USE " + db + "\n" + "EXEC " + storedProc);
164+
executeQuery("USE [" + db + "]\n" + "EXEC " + storedProc);
162165
}
163166

164167
@Override
@@ -313,6 +316,15 @@ void testCdcCheckOperations() throws Exception {
313316
assertEquals(status.getStatus(), AirbyteConnectionStatus.Status.FAILED);
314317
}
315318

319+
320+
@Test
321+
void testCdcCheckOperationsWithDot() throws Exception {
322+
// assertCdcEnabledInDb and validate escape with special character
323+
switchCdcOnDatabase(true, dbNamewithDot);
324+
AirbyteConnectionStatus status = getSource().check(getConfig());
325+
assertEquals(status.getStatus(), AirbyteConnectionStatus.Status.SUCCEEDED);
326+
}
327+
316328
// todo: check LSN returned is actually the max LSN
317329
// todo: check we fail as expected under certain conditions
318330
@Test

docs/integrations/sources/mssql.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ If you do not see a type in this list, assume that it is coerced into a string.
306306

307307
| Version | Date | Pull Request | Subject |
308308
|:--------|:-----------| :----------------------------------------------------- |:-------------------------------------------------------------------------------------------------------|
309+
| 0.4.13 | 2022-08-04 | [15268](https://github.com/airbytehq/airbyte/pull/15268) | Added [] enclosing to escape special character in the database name|
309310
| 0.4.12 | 2022-08-02 | [14801](https://github.com/airbytehq/airbyte/pull/14801) | Fix multiply log bindings |
310311
| 0.4.11 | 2022-07-22 | [14714](https://github.com/airbytehq/airbyte/pull/14714) | Clarified error message when invalid cursor column selected |
311312
| 0.4.10 | 2022-07-14 | [14574](https://github.com/airbytehq/airbyte/pull/14574) | Removed additionalProperties:false from JDBC source connectors |

0 commit comments

Comments
 (0)