Skip to content

Fix SQL Server defaults when modifying columns - #320

Merged
elpete merged 2 commits into
nextfrom
fix/issue-152-sqlserver-modify-default
Aug 12, 2026
Merged

Fix SQL Server defaults when modifying columns#320
elpete merged 2 commits into
nextfrom
fix/issue-152-sqlserver-modify-default

Conversation

@elpete

@elpete elpete commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Closes #152

What changed

  • remove an existing SQL Server default constraint before altering a column with a new default
  • discover the existing constraint through SQL Server system catalogs so custom constraint names are supported
  • add the requested default back as a valid standalone constraint after the column alteration
  • add a regression test using the reproduction from the issue

Root cause

The SQL Server modify-column compiler reused the create-column compiler, which placed CONSTRAINT ... DEFAULT inline in an ALTER COLUMN statement. SQL Server does not accept default constraints in that position.

Validation

  • TestBox on Lucee 6: 2,773 passed, 0 failed, 3 skipped
  • box run-script format:check
  • git diff --check

@elpete

elpete commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Updated the implementation to address the dynamic-SQL injection concern:

  • the EXEC statement no longer interpolates caller-provided table names
  • schema and table names are resolved from SQL Server catalog metadata and passed through QUOTENAME
  • SQL Server identifier wrapping now escapes closing brackets as ]]
  • added an adversarial regression test covering apostrophes and closing brackets in table and column names

Validation: Lucee suite 2,915 passed, 0 failed/errors, 3 skipped; formatting and git diff --check pass.

@elpete
elpete marked this pull request as ready for review August 12, 2026 18:45
@elpete
elpete merged commit c18d84c into next Aug 12, 2026
34 of 35 checks passed
@elpete
elpete deleted the fix/issue-152-sqlserver-modify-default branch August 12, 2026 18:45
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

Successfully merging this pull request may close these issues.

1 participant