-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Now MetaDataFilter takess also regexp. For example whern you want to #507
Conversation
extract metadata if you would filter like this: --filter="Article" would extract also for "ArticleItems" (article_items table). Now you can use --filter="Article$" if you want only that table (articl)
Hello, thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link: |
This does not follow the coding standards. |
if (strpos($metadata->name, $filter) !== false) { | ||
return true; | ||
} | ||
if(preg_match("#$filter#",$metadata->name,$m)) return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after the if
. Also you need to add {
around the statement as defined in PSR-1/2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and you need to escape the #
in the filter as you use it as regex delimiter
- Changed RegExp format
@@ -51,7 +51,7 @@ static public function filter(array $metadatas, $filter) | |||
|
|||
public function __construct(\ArrayIterator $metadata, $filter) | |||
{ | |||
$this->filter = (array) $filter; | |||
$this->filter = (array)$filter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep this space
…dard, but I modified in PhpStorm)
throw new ORMException("Error regular expression: " . $filter);
@@ -66,7 +66,16 @@ public function accept() | |||
$metadata = $it->current(); | |||
|
|||
foreach ($this->filter as $filter) { | |||
if (strpos($metadata->name, $filter) !== false) { | |||
$pregResult = preg_match("/" . preg_quote($filter) . "/", $metadata->name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot use preg_qoute here, if you do so, $filter
will not be treated as a regular expression (which was the intention of this pull request). And even if you do so, you still do not escape the delimiter, you would have to do this: preg_quote($filter, '/')
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true. I realized that after I pushed the code. Some unit test might be helpfull here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove the preg_quote()
Merged into master. |
extract metadata if you would filter like this: --filter="Article"
would extract also for "ArticleItems" (article_items table). Now you
can use --filter="Article$" if you want only that table (articl)