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

Fix caching for insert queries with fragments #177

Merged
merged 5 commits into from
Mar 28, 2024
Merged

Conversation

msmakouz
Copy link
Member

What's was changed

The caching of insert queries with fragments has been fixed.

The hash of the cached query did not take into account the number of fragments used in the query. That is, if in the first query we use two fragments, its hash is generated and we save the generated query:

$insert = $database->insert()->into('table')->values([
    'name' => 'John Doe',
    'updated_at' => new Expression('NOW()'),
    'deleted_at' => new Expression('NOW()'),
]);

Then comes a query where the number of fragments is different; its generated hash will be the same, but the generated SQL will be different:

$insert = $database->insert()->into('table')->values([
    'name' => 'John Doe',
    'updated_at' => new Expression('NOW()'),
    'deleted_at' => null,
]);

Another situation may occur where the number of fragments is the same, but their content is different. This has been fixed. Now the query hash takes into account the fragments and their content.

Closes: #176

@msmakouz msmakouz added the type:bug Bug label Mar 28, 2024
@msmakouz msmakouz added this to the 2.9.x milestone Mar 28, 2024
@msmakouz msmakouz requested a review from roxblnfk March 28, 2024 10:39
@msmakouz msmakouz self-assigned this Mar 28, 2024
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.27%. Comparing base (9eb6669) to head (3c50583).

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x     #177      +/-   ##
============================================
+ Coverage     95.25%   95.27%   +0.02%     
- Complexity     1838     1839       +1     
============================================
  Files           130      130              
  Lines          5075     5077       +2     
============================================
+ Hits           4834     4837       +3     
+ Misses          241      240       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@msmakouz msmakouz merged commit ab00319 into 2.x Mar 28, 2024
41 checks passed
@msmakouz msmakouz deleted the bugfix/fragments-cache branch March 28, 2024 16:12
This was referenced Mar 29, 2024
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.

Cycle\Database\Injection\Expression caching issue
3 participants