-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Add WITH support #334
Add WITH support #334
Conversation
Codecov Report
@@ Coverage Diff @@
## master #334 +/- ##
============================================
+ Coverage 95.45% 95.53% +0.08%
- Complexity 1969 2009 +40
============================================
Files 65 67 +2
Lines 4203 4303 +100
============================================
+ Hits 4012 4111 +99
- Misses 191 192 +1
Continue to review full report at Codecov.
|
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.
Parfait !
91d2de5
to
77ffd9d
Compare
Hello, |
2bee1c8
to
a22dc44
Compare
Hi @phpmyadmin/developers |
public static function build($component, array $options = []) | ||
{ | ||
if (! $component instanceof WithKeyword) { | ||
throw new RuntimeException('Can not build a component that is not a WithKeyword'); |
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 about LogicException ?
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.
LogicException are more often used outside of running code, at compile time, here as we would hit that during the "runtime" it's more appropriate. See also https://stackoverflow.com/questions/5586404/logicexception-vs-runtimeexception.
I hesitated here, and I even wanted to pick an exception of the package but ParseException wasn't a good fit.
} | ||
|
||
$this->count = count($tokens); | ||
$this->count = $count === -1 ? count($tokens) : $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.
You change the behavior, are you sure ? 😃
Before $this->count
was equal to 0
as we return earlier
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.
Yes, there was a bug in the parser actually. count
here should always be the value of the array's length.
|
||
$str .= ' AS ('; | ||
|
||
foreach ($component->statement->statements as $statement) { |
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.
maybe check that statement->statements
is an iterable, on line 45 you just check that it's isset
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.
As component->statement
should be typed to Parser
and that Parser
has a public $statements = [];
we're fine :).
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.
Thank you for the new reviews !!
Did you manually test the binaries in ./bin/
?
Thank you :) |
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.
Thanks for working on this @soyuka! LGTM 👍 💯
Pull-request: #334 Signed-off-by: William Desportes <[email protected]>
Hi, while working on other issues related to the
I'm wondering, shouldn't we also parse the part that follows the For now, the parser will not throw any error for such queries: WITH cte (col1, col2) AS ( SELECT 1, 2 UNION ALL SELECT 3, 4 ) FROM cte; As i'm currently working on making the What do you think? I might be missing something though. |
It seems to make sense to handle this in WithStatement and not in another statement |
Cool, I don't think it would be that difficult to implement, I will work on it. Hopefully I can manage to finish it along with the other issues related to it, before the end of the week. |
Fixes: #165
Fixes: #331