CodeWithPravinMaske opened a new pull request, #12596:
URL: https://github.com/apache/seatunnel/pull/12596
### Purpose of this pull request
Follow-up to #10323 / #10327.
#10327 added `[...]` quoting for SQL Server database names that contain
special characters such as `-` (for example `gssd-gsp_mes`).
`SqlServerCatalog.getDropTableSql` was missed and still builds an unquoted name:
```sql
DROP TABLE gssd-gsp_mes.dbo.my_table -- Incorrect syntax near '-'
```
So `schema_save_mode = RECREATE_SCHEMA` (which drops the table) still fails
for such databases, while `CREATE TABLE`, `TRUNCATE TABLE` and the exists-data
check already quote the path.
This PR quotes the table path the same way as the other statements:
```java
return String.format("DROP TABLE %s", tablePath.getFullNameWithQuoted("[",
"]"));
```
### Does this PR introduce _any_ user-facing change?
Yes, a bug fix: `DROP TABLE` (used by `RECREATE_SCHEMA`) now works for SQL
Server databases, schemas and tables whose names need quoting. The generated
SQL for normal names is equivalent (`[db].[schema].[table]`). No option or
default changes.
### How was this patch tested?
- `PreviewActionTest`: the expected SQL Server `DROP_TABLE` preview is now
`DROP TABLE [testddatabase].[testtable]` (7/7 pass).
- `JdbcSqlServerIT#testCatalog` (real SQL Server 2022 container): extended
to create a database named `test-db`, create a table in it, drop the table and
the database. It passed locally.
### Check list
* [x] If any new Jar binary package adding in your PR, please add License
Notice according
[New License
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
— N/A, no new jar.
* [x] If necessary, please update the documentation to describe the new
feature. — N/A, bug fix with no documented behavior change.
* [x] If necessary, please update `incompatible-changes.md` to describe the
incompatibility caused by this PR. — N/A, no incompatibility.
* [x] If you are contributing the connector code, please check that the
following files are updated: — N/A, fix to an existing connector.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]