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

Fixed regex to allow matching namespaces in ClassName #61

Open
wants to merge 1 commit into
base: 2.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/MSSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ protected function alterTableAlterColumn($tableName, $colName, $colSpec)
// First, we split the column specifications into parts
// TODO: this returns an empty array for the following string: int(11) not null auto_increment
// on second thoughts, why is an auto_increment field being passed through?
$pattern = '/^(?<definition>[\w()]+)\s?(?<null>(?:not\s)?null)?\s?(?<default>default\s[\w\']+)?\s?(?<check>check\s?[\w()\'",\s]+)?$/i';
$pattern = '/^(?<definition>[\w()]+)\s?(?<null>(?:not\s)?null)?\s?(?<default>default\s[\w\'\\\\]+)?\s?(?<check>check\s?[\w()\'"\\\\,\s]+)?/i';
Copy link
Contributor

@tractorcow tractorcow Mar 15, 2021

Choose a reason for hiding this comment

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

What other characters could the default have? Spaces, underscore, etc? Feels like regexp is totally the wrong way to go about this hah. (isn't it normally?) :P

Maybe match word characters without quotes, but also match a quoted entity that contains everything except a quote?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

May as well unit test it right? :P

$matches = array();
preg_match($pattern, $colSpec, $matches);

Expand Down