Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defncopy: index names not properly escaped #429

Closed
jonahgeorge opened this issue Nov 21, 2021 · 4 comments
Closed

defncopy: index names not properly escaped #429

jonahgeorge opened this issue Nov 21, 2021 · 4 comments

Comments

@jonahgeorge
Copy link

jonahgeorge commented Nov 21, 2021

It appears that defncopy does not properly escape index names when writing the create index command.

I was able to reproduce this on an existing table which has a column named FromDate and an index on said column named From Date:

CREATE TABLE dbo.tblReportPeriod
	( [RecordID]   int             NOT NULL
	, [FromDate]   nvarchar(40)        NULL
	, [ToDate]     nvarchar(40)        NULL
	)

CREATE  nonclustered INDEX [From Date] on dbo.tblReportPeriod([FromDate])

defncopy generated the following invalid SQL:

CREATE TABLE dbo.tblReportPeriod
	( RecordID   int             NOT NULL
	, FromDate   nvarchar(40)        NULL
	, ToDate     nvarchar(40)        NULL
	)

CREATE  nonclustered INDEX From Date on dbo.tblReportPeriod(FromDate)

Related

@jonahgeorge
Copy link
Author

Per comments in the linked PR, if this were to be fixed it appears that defncopy would need to know which quoting strategy to use (brackets for MSSQL vs quotes elsewhere). Would a CLI flag be acceptable?

@fziglio
Copy link

fziglio commented Nov 22, 2021

Sybase 15 introduced [] quoting so I think it would be safe now to use always [] style quoting. One issue of the PR is that it's not properly quoting. If the name is test]123 it needs to be quoted as [test]]123], not [test]123]. There's a tds_quote_id to quote identifier (there's also an internal tds_quote function).

@Michoels
Copy link

This is still a problem in 2024.

@freddy77
Copy link
Contributor

Fixed in 1.4.12 (will be packaged automatically tomorrow) and master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants