-
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
Pg schema support #159
Pg schema support #159
Conversation
c82a3c0
to
f1ed945
Compare
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 really like this idea. Can we have this for mysql / mariadb as well?
src/Util/PostgresHelper.php
Outdated
*/ | ||
private function quoteIdent(string $tableName): string | ||
{ | ||
return array_reduce(explode('.', $tableName), function ($result, $part) { |
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.
that's really hard to read, can we simplify that?
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.
ready
src/Util/PostgresHelper.php
Outdated
*/ | ||
private function extractSchema(string $identifier): ?string | ||
{ | ||
$parts = array_map(function ($part) { |
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.
same 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.
ready
@@ -0,0 +1,12 @@ | |||
CREATE SCHEMA IF NOT EXISTS custom; |
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 don't know if "custom" is a good default, why not "prooph" 😄
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.
ready
Thank you for review! I'll fix it. |
You're right, thanks. So no worries.
Can you also please make sure that existing app configurations are not
broken and the use of additional schema is optional?
…On Fri, May 25, 2018, 17:53 Vladimir Vershinin ***@***.***> wrote:
Thank you for review! I'll fix it.
As I know in MySQL/MariaDB schema represents another database and
probably with another connection configuration. Currently I don't know how
to deal with this
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#159 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAYEvIx7me5fkeHKNDIn1Mc5-LWltpazks5t19SYgaJpZM4UNdJd>
.
|
Tables for event streams and projections will be created in custom schema only if |
May I asked why it's a requirement to have schemas in your project? |
Sure, it just an our internal convention: not to create all at public schema (pg extensions usually creates here functions, tables and etc.), each module adds tables, functions and etc in it's own schema, so it easy to search in relatively large db |
👍 I'll recheck this PR this weekend. |
Ok , thank you |
I'll have to make some more testing, I don't like this quoting method, I hope to come up with a faster solution. Currently really busy. |
@ghettovoice I think I found a much faster quoting-function, see https://3v4l.org/7bCYi |
@prolic I see 👍 |
Can you try to work this out yourself? I have time to check this maybe the
weekend.
Sascha-Oliver Prolic
2018-05-30 16:46 GMT+08:00 Vladimir Vershinin <[email protected]>:
… @prolic <https://github.com/prolic> I see 👍
My implementation uses two functions because of needless schema extraction
in generateTableName
method e1b9a7b#diff-6895a5b565f06c33a1404ad8257df13e
<e1b9a7b#diff-6895a5b565f06c33a1404ad8257df13e>
.
May be here should be another solution for persistence strategy?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#159 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAYEvNmnOHiZ60l-JoBwwpzKH3s7TrNsks5t3lx4gaJpZM4UNdJd>
.
|
Ok, I'll try to make this before weekends |
re-implement `quoteIdent` and `splitIdent` according to https://3v4l.org/7bCYi and https://3v4l.org/QcCCl to increase quoting performance.
'_' . sha1($streamName->toString()), | ||
])); | ||
if ($schema) { | ||
$schema . '.' . $table; |
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.
That doesn't make any sense
'_' . sha1($streamName->toString()), | ||
])); | ||
if ($schema) { | ||
$schema . '.' . $table; |
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.
same here
'_' . sha1($streamName->toString()), | ||
])); | ||
if ($schema) { | ||
$schema . '.' . $table; |
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 again, maybe you should add a unit test for this method
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.
Oh, sorry! You are right. I thought that the test already exists
- fix generateTableName method in Postgres related persistence strategy classes - add tests for generateTableName method
Now it's done. Yesterday I made it late at night |
src/Util/PostgresHelper.php
Outdated
* @param string $ident | ||
* @return string[] | ||
*/ | ||
private function splitIdent(string $ident): array |
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.
On reviewing I found that the returned table name is not used at all. So why not change the signature then? Something like private function schema(string $ident): ?string
. It either returns the schema or null
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 private function extractSchema(string $ident): ?string
in the very first version.
I'll fix this
… - an simplified extraction of pg schema from 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.
GOOD WORK! thanks you
Thank you for your time! |
This pull request adds support of multi schema events stores and projection for PostresSQL implementation #157 .
Summary (only Pg related classes):
I added additional tests to clarify the new behaviour