-
Notifications
You must be signed in to change notification settings - Fork 19
Provide a default prefix to compile
in sqlStatement
#63
base: master
Are you sure you want to change the base?
Provide a default prefix to compile
in sqlStatement
#63
Conversation
…ctiveQuery The prefix property in ActiveQuery is a nullable string, but the `compile` method in CompilerInterface expects a string. We provide an empty string if the prefix property is null.
I wasn’t able to run the test suite, but it seems like the CI setup itself is broken, so I guess it’s alright. Plus it’s really a small and safe change I think. |
Codecov Report
@@ Coverage Diff @@
## master #63 +/- ##
============================================
- Coverage 92.90% 92.55% -0.35%
- Complexity 1476 1488 +12
============================================
Files 67 67
Lines 3804 3842 +38
============================================
+ Hits 3534 3556 +22
- Misses 270 286 +16
Continue to review full report at Codecov.
|
src/Query/ActiveQuery.php
Outdated
@@ -105,7 +105,7 @@ public function sqlStatement(QueryParameters $parameters = null): string | |||
|
|||
return $this->driver->getQueryCompiler()->compile( | |||
$parameters ?? new QueryParameters(), | |||
$this->prefix, | |||
$this->prefix ?? "", |
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 suggest using single quotes instead of double quotes. It’ll be more consistent
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.
Done!
Should we re-run the checks for this PR? I think the CI setup was kind of broken at the time. |
Sounds like we can't do it anymore... |
@SerafimArts do you have any idea how to rerun it? |
Maybe add some unimportant commit? Something like that: $compiler = $this->driver->getQueryCompiler();
return $compiler->compile(
$parameters ?? new QueryParameters(),
$this->prefix,
$this
); |
@SerafimArts Done! |
@wolfy-j it seems it worked =) |
@roxblnfk we have to copy it to the cycle/database as well. |
So the test suite fails under MySQL 5.7 but apparently the same test was already failing. |
When creating an ActiveQuery without a prefix (which is possible since the prefix property is nullable), the
sqlStatement
method fails since it passes the prefix property to$this->driver->getQueryCompiler()->compile
which expects a string. I suggest to fallback to an empty string when the prefix property is null.