Skip to content

Allow dashes in ShorthandReference#260

Open
ed-fbiberger wants to merge 3 commits intobitol-io:devfrom
ed-fbiberger:fix-shorthand-reference-dashes
Open

Allow dashes in ShorthandReference#260
ed-fbiberger wants to merge 3 commits intobitol-io:devfrom
ed-fbiberger:fix-shorthand-reference-dashes

Conversation

@ed-fbiberger
Copy link
Copy Markdown
Contributor

Hey,
we recognised that the regular expressions for ShorthandReference is too restrictive.
At the moment it does not allow - as character being used. As table names for some technologies sometimes can contain this character, it breaks contract validation in those cases. E.g.

table-name.column_name

is not possible with the current regex:

^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)+$

I updated this to:

^[A-Za-z_][A-Za-z0-9_\-]*(\\.[A-Za-z_][A-Za-z0-9_\-]*)+$

so that table names with dashes are supported.

@ed-fbiberger ed-fbiberger requested a review from a team as a code owner April 21, 2026 08:44
"type": "string",
"description": "Shorthand notation using name fields (table_name.column_name)",
"pattern": "^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)+$"
"pattern": "^[A-Za-z_][A-Za-z0-9_\\-]*(\\.[A-Za-z_][A-Za-z0-9_\\-]*)+$"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the escape character necessary for dashes in regex?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, but I find it easier to read, as the dash is also used with semantical meaning in ranges e.g. a-z. I found both usages in ODCS schema and decided to use it with escape char, but can easily be changed.

@ed-fbiberger ed-fbiberger force-pushed the fix-shorthand-reference-dashes branch from 142f273 to 9063bfa Compare April 21, 2026 09:00
@ed-fbiberger
Copy link
Copy Markdown
Contributor Author

Added an example that checks, if shorthand references are usable with dashes.

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.

2 participants