database icon indicating copy to clipboard operation
database copied to clipboard

Provide a default prefix to `compile` in `sqlStatement`

Open sylbru opened this issue 4 years ago • 10 comments

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.

sylbru avatar Mar 10 '21 11:03 sylbru

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.

sylbru avatar Mar 10 '21 11:03 sylbru

Codecov Report

Merging #63 (9f0a620) into master (5ae0a62) will decrease coverage by 0.34%. The diff coverage is 100.00%.

Impacted file tree graph

@@             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     
Impacted Files Coverage Δ
src/Query/ActiveQuery.php 91.66% <100.00%> (+0.23%) :arrow_up:
src/Driver/Driver.php 76.44% <0.00%> (-6.17%) :arrow_down:
src/Driver/Postgres/PostgresDriver.php 81.25% <0.00%> (-1.29%) :arrow_down:
src/Schema/AbstractColumn.php 94.41% <0.00%> (-0.09%) :arrow_down:
src/Driver/MySQL/MySQLCompiler.php 100.00% <0.00%> (ø)
src/Driver/Compiler.php 95.13% <0.00%> (+0.08%) :arrow_up:
src/DatabaseManager.php 98.48% <0.00%> (+0.12%) :arrow_up:
src/Query/SelectQuery.php 95.49% <0.00%> (+0.25%) :arrow_up:
src/Driver/SQLite/SQLiteCompiler.php 95.55% <0.00%> (+0.43%) :arrow_up:
src/Query/InsertQuery.php 100.00% <0.00%> (+5.00%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a729662...9f0a620. Read the comment docs.

codecov[bot] avatar Mar 10 '21 11:03 codecov[bot]

Should we re-run the checks for this PR? I think the CI setup was kind of broken at the time.

sylbru avatar Jul 20 '21 19:07 sylbru

Sounds like we can't do it anymore...

wolfy-j avatar Jul 26 '21 12:07 wolfy-j

@SerafimArts do you have any idea how to rerun it?

wolfy-j avatar Jul 26 '21 12:07 wolfy-j

Maybe add some unimportant commit? Something like that:

$compiler = $this->driver->getQueryCompiler();

return $compiler->compile(
    $parameters ?? new QueryParameters(),
    $this->prefix,
    $this
);

SerafimArts avatar Jul 26 '21 15:07 SerafimArts

@SerafimArts Done!

sylbru avatar Jul 30 '21 10:07 sylbru

@wolfy-j it seems it worked =)

SerafimArts avatar Jul 30 '21 10:07 SerafimArts

@roxblnfk we have to copy it to the cycle/database as well.

wolfy-j avatar Jul 30 '21 11:07 wolfy-j

So the test suite fails under MySQL 5.7 but apparently the same test was already failing.

sylbru avatar Jul 30 '21 15:07 sylbru