-
Notifications
You must be signed in to change notification settings - Fork 59
Projection manager, Updates & Bugfixes #59
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
Conversation
|
/cc @oqq |
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.
👍
src/MySqlEventStore.php
Outdated
| if (null === $factory) { | ||
| $factory = $this->getDefaultReadModelProjectionFactory(); | ||
| if (null !== $filter) { | ||
| $where[] = '`real_stream_name` = :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.
unnecessary space on the end of string
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.
ok
src/MySqlEventStore.php
Outdated
| } | ||
|
|
||
| if ($regex && false === @preg_match("/$filter/", '')) { | ||
| if (false === @preg_match("/$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.
error suppression, you know. ;)
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.
register and unregister error handler for a single line of code is much slower I think.
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.
The whole test could be omitted and simply catched from mysql.
ERROR 1139 (42000): Got error '%s' from regexp
Not sure about postgre.
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 would also fail with an empty $filter string.
preg_match("//", ''); is fine, but
SELECT 1 REGEXP '' ERROR 1139 (42000): Got error 'empty (sub)expression' from regexp
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.
I can catch error code from postgres 2201B to check for invalid regex.
Mysql error code 42000 "Got error 'empty (sub)expression' from regexp" works for empty string, but another invalid regex is accepted without error. Another thing is error code 42000 in MySql is used for different reasons. Really bad.
So we can make this change for postgres, but not MySql so much.
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.
What is the result for invalid regex.. no result? Thats bad :(
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.
yep, it just returns empty result, no error code at all.
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.
sadly.. than this extra call is necessary :(
But $filter should not be empty, too. To protect for that sql error.
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.
already done.
src/MySqlEventStore.php
Outdated
| $where[] = '`real_stream_name` = :filter '; | ||
| $values[':filter'] = $filter; | ||
| } | ||
| $where[] = '`real_stream_name` REGEXP :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.
unnecessary space
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.
ok
src/PostgresEventStore.php
Outdated
| if (null === $factory) { | ||
| $factory = $this->getDefaultReadModelProjectionFactory(); | ||
| if (null !== $filter) { | ||
| $where[] = 'real_stream_name = :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.
space..
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.
ok
src/PostgresEventStore.php
Outdated
| $where[] = 'real_stream_name = :filter '; | ||
| $values[':filter'] = $filter; | ||
| } | ||
| $where[] = 'real_stream_name ~ :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.
space..
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.
ok
| public function fetchProjectionStreamPositions(string $name): array | ||
| { | ||
| $query = <<<SQL | ||
| SELECT position FROM $this->projectionsTable |
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.
backticks
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.
Postgres does not allow backticks
| public function fetchProjectionState(string $name): array | ||
| { | ||
| $query = <<<SQL | ||
| SELECT state FROM $this->projectionsTable |
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.
backticks
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.
Postgres does not allow backticks
| $this->expectException(InvalidArgumentException::class); | ||
|
|
||
| $eventStore = $this->prophesize(EventStore::class); | ||
| $connection = $this->prophesize(\PDO::class); |
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.
unnecessary backslash on \PDO
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.
ok
| $this->expectException(InvalidArgumentException::class); | ||
|
|
||
| $eventStore = $this->prophesize(EventStore::class); | ||
| $connection = $this->prophesize(\PDO::class); |
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.
unnecessary backslash \PDO
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.
ok
| $this->expectException(InvalidArgumentException::class); | ||
|
|
||
| $eventStore = $this->prophesize(EventStore::class); | ||
| $connection = $this->prophesize(\PDO::class); |
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.
unnecessary backslash
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.
ok
|
|
||
| if (! empty($whereCondition)) { | ||
| $whereCondition = 'WHERE ' . $whereCondition; | ||
| $whereCondition = 'WHERE ' . implode(' AND ', $where); |
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.
Could be
$whereCondition = 'WHERE `name` = :filter';
$values[':filter'] = $filter;|
|
||
| if (! empty($whereCondition)) { | ||
| $whereCondition = 'WHERE ' . $whereCondition; | ||
| $whereCondition = 'WHERE ' . implode(' AND ', $where); |
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.
Could be
$whereCondition = 'WHERE name = :filter';
$values[':filter'] = $filter;
see prooph/event-store#267
the event store PR is required for travis to turn green.