-
Notifications
You must be signed in to change notification settings - Fork 58
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
use prepared load statements #44
use prepared load statements #44
Conversation
@@ -78,7 +76,6 @@ public function __construct( | |||
PDO $connection, | |||
PDOStatement $statement, | |||
MessageFactory $messageFactory, | |||
array $sql, | |||
?int $batchSize, | |||
int $fromNumber, | |||
int $count, |
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.
is bool forward
still needed then?
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.
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.
ah ok
{ | ||
$limit = $this->count < ($this->batchSize * ($this->batchPosition + 1)) | ||
? $this->count - ($this->batchSize * $this->batchPosition) | ||
: $this->batchSize; | ||
|
||
if ($this->forward) { |
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.
see you removed forward
$sql['where'][] = "metadata ->> '$field' $operator $value"; | ||
} else { | ||
$sql['where'][] = "metadata ->> '$field' $operator '$value'"; | ||
$where[] = "metadata->'$field' $operator '".var_export($value, 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.
metadata ->>
instead of metadata ->
see: https://www.postgresql.org/docs/9.3/static/functions-json.html
->
means: Get JSON object field
->>
means: Get JSON object field as text
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 am not sure about that, but mysql declares
->>
as shortcut for JSON_UNQUOTE(JSON_EXTRACT()), and
->
as shortcut for JSON_EXTRACT()
So ->>
is always an extra step. With ->
all tests passes. Maybe Postgre is fine with. Should we add an extra step?
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.
no, ok when it works
$value = var_export($value, true); | ||
} elseif (is_string($value)) { | ||
$value = $this->connection->quote($value); | ||
$where[] = "metadata->\"$.$field\" $operator ".var_export($value, 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.
I think this should be metadata->>
to unquote.
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.
Than it would also match 'true' === true. Right?
great work! thx! 👍 |
Currently the queries in aggregate load methods from event stores builds queries and recreate this for batch requests.
This PR changes this behavior and implements prepared statements. The PdoStreamIterator has only to change the values for
fromNumber
andlimit
without have to know how to queries should be builded.