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

provides default dsn value for charset in factories #56

Merged
merged 6 commits into from
Feb 17, 2017

Conversation

oqq
Copy link
Member

@oqq oqq commented Feb 17, 2017

If anyone trusts the default config (e.g. me), than this person could get bad experience with the mysql event store without this PR.

json_decode() would return null with an invalid json string, e.g. a not correct utf-8 encoded string.
Which would end up with Assert\InvalidArgumentException: payload must be an array.

Anyway.. if there is no reason why the default charset should not be utf-8, this PR should be merged before next stable release to prevent for bc breaks.

@prolic
Copy link
Member

prolic commented Feb 17, 2017

wrong for postgres - build fails

@prolic
Copy link
Member

prolic commented Feb 17, 2017

must be something like: pg_connect("host=localhost options='--client_encoding=UTF8'");

@oqq
Copy link
Member Author

oqq commented Feb 17, 2017

how about to provide the dsn from the entire factory instead of in the abstract one?
Maybe a getDsn method could help. Meanings?

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 1785398 on oqq:improvement/charset_in_factories into ** on prooph:master**.

@oqq
Copy link
Member Author

oqq commented Feb 17, 2017

@oqq
Copy link
Member Author

oqq commented Feb 17, 2017

I have added my proposal and have extended tests. Please review again @prolic .

public function defaultOptions(): iterable
{
return [
'connection_options' => [
'driver' => 'pdo_pgsql',
Copy link
Member

Choose a reason for hiding this comment

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

Why is that removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is not needed anymore.

@@ -45,6 +45,7 @@ public static function getConnection(): PDO
$dsn .= 'dbname=' . $connectionParams['dbname'] . $separator;
$dsn = rtrim($dsn);
self::$connection = new PDO($dsn, $connectionParams['user'], $connectionParams['password']);
self::$connection->query("SET NAMES '".$connectionParams['charset']."'");
Copy link
Member

Choose a reason for hiding this comment

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

Why not via connection options?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have not found a connection option which would work for postgre. Thats the way how doctrine is bypass this issue.

);

if (isset($config['connection_options']['charset'])) {
$connection->query("SET NAMES '".$config['connection_options']['charset']."'");
Copy link
Member

Choose a reason for hiding this comment

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

Why not use connection options?

Copy link
Member Author

Choose a reason for hiding this comment

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

The connection option for charset is used in mysql factory. This is a workaround for postgre.

@prolic
Copy link
Member

prolic commented Feb 17, 2017

Try options='--client_encoding=UTF8' for PostgreSQL

@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 98.403% when pulling dbb500f on oqq:improvement/charset_in_factories into ca422ed on prooph:master.

@oqq
Copy link
Member Author

oqq commented Feb 17, 2017

@prolic any reason why you have used a space as separator for postgre? It seems that postgre is fine with ';' as separator.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 98.403% when pulling 4e897ae on oqq:improvement/charset_in_factories into ca422ed on prooph:master.

@prolic prolic added the bug label Feb 17, 2017
@prolic prolic self-assigned this Feb 17, 2017
@prolic
Copy link
Member

prolic commented Feb 17, 2017

@prolic any reason why you have used a space as separator for postgre? It seems that postgre is fine with ';' as separator.

As far as I know ; doesn't work for postgres.

@prolic prolic merged commit 23d5b7b into prooph:master Feb 17, 2017
@oqq oqq deleted the improvement/charset_in_factories branch February 18, 2017 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants