Skip to content

Fix bug in DBML column default rendering with single quotes#45

Merged
Vanderhoof merged 1 commit into
Vanderhoof:masterfrom
ryanproback:feature/fix-column-default-escapse
Nov 28, 2024
Merged

Fix bug in DBML column default rendering with single quotes#45
Vanderhoof merged 1 commit into
Vanderhoof:masterfrom
ryanproback:feature/fix-column-default-escapse

Conversation

@ryanproback
Copy link
Copy Markdown

This PR fixes a bug in the DBML renderer where column default values containing single quotes (') were rendered in a syntax-breaking format.

Issue:

When rendering column defaults with single quotes, the output would generate invalid DBML syntax. For example:

col1 varchar [default: 'b'0'']  // syntax error!

Fix

The default_to_str function now uses the prepare_text_for_dbml utility to ensure that single quotes are properly escaped, resulting in valid DBML syntax. For example:

col1 varchar [default: 'b\'0\'']  // ok

Changes

  • Bug fix: Integrated prepare_text_for_dbml into the default_to_str function for proper escaping of single quotes and other special characters in column default values.
  • Test updates: Added a new test case to validate this fix using a binary string example (b'0').

- Integrated `prepare_text_for_dbml` into `default_to_str` for consistent handling of special characters in DBML column strings.
- Updated the test suite to include a new test case for handling binary string input (`b'0'`).
@Vanderhoof
Copy link
Copy Markdown
Owner

Awesome, thanks a lot 👍

@Vanderhoof Vanderhoof merged commit 30cecc2 into Vanderhoof:master Nov 28, 2024
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.

3 participants