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

Process expressions inside param values when build a query #806

Merged
merged 34 commits into from
Apr 12, 2024

Conversation

Tigrov
Copy link
Member

@Tigrov Tigrov commented Feb 6, 2024

  • Allows non-unique param names inside Expression::$params (they will be replaced with unique names)
  • Process Expression instances inside Expression::$params

Related PRs

Q A
Is bugfix? ✔️
New feature? ✔️/❌
Breaks BC?
Fixed issues #805

Copy link

what-the-diff bot commented Feb 6, 2024

PR Summary

  • Addition of new file AbstractExpressionBuilder.php
    A new file that contains the AbstractExpressionBuilder class is added to help in the creation of various expressions for database queries.

  • Removal of ExpressionBuilder.php
    The ExpressionBuilder class, previously used for building expressions, is no longer needed. The file containing this class was deleted.

  • Changes in AbstractDQLQueryBuilder.php
    Several method modifications were made to simplify the building of queries. A significant change is that these methods now return a string rather than being void, and also receive additional parameters. The methods also utilize the quoter property for quoting column names.

  • Introduction of AbstractSqlParser.php
    This new file has the AbstractSqlParser class, which assists in parsing SQL statements and extracting placeholders from them.

  • Test adjustments in AbstractQueryBuilderTest.php & CommonCommandTest.php
    Tests were adjusted to now compare the quoted SQL output, a change to improve test accuracy. Also, several method parameters were modified to streamline and refine the testing process.

  • Addition of AbstractSqlParserTest.php
    This file was added to contain test cases for the new AbstractSqlParser class.

  • Modifications in QueryBuilderTest.php
    Similar to the other test modifications, this file had changes to test parameters and comparisons of quoted SQL output.

  • Addition of tests and cases in CommandProvider.php
    New test cases, with nested expressions and new parameters, were added to improve testing comprehensiveness.

  • Addition of new files
    Several new files, each containing specific classes and functionalities have been added. These include SqlParserProvider.php, DQLQueryBuilder.php, ExpressionBuilder.php, and SqlParser.php. These contribute to broadening the system's functionalities.

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.56%. Comparing base (749c3f3) to head (fe50046).
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #806      +/-   ##
============================================
+ Coverage     99.55%   99.56%   +0.01%     
- Complexity     1277     1316      +39     
============================================
  Files            63       64       +1     
  Lines          3120     3228     +108     
============================================
+ Hits           3106     3214     +108     
  Misses           14       14              

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

@samdark samdark requested review from darkdef and terabytesoftw and removed request for darkdef February 8, 2024 08:59
@Tigrov Tigrov requested a review from vjik February 11, 2024 12:58
@Tigrov Tigrov added the status:code review The pull request needs review. label Feb 13, 2024
src/Expression/ExpressionBuilder.php Outdated Show resolved Hide resolved
src/Expression/ExpressionBuilder.php Outdated Show resolved Hide resolved
@Tigrov Tigrov requested a review from vjik March 30, 2024 10:43
src/Syntax/SqlParser.php Outdated Show resolved Hide resolved
@Tigrov Tigrov added this to the 2.0.0 milestone Apr 6, 2024
UPGRADE.md Outdated Show resolved Hide resolved
src/Expression/AbstractExpressionBuilder.php Outdated Show resolved Hide resolved
src/Expression/AbstractExpressionBuilder.php Show resolved Hide resolved
*/
public function __construct(protected string $sql)
{
$this->length = strlen($sql);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could SQL contain unicode strings?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll check this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problems with UTF-8 or any single-byte encoding.

Should it support other multibyte encodings? If should, it could be a problem to pass that encoding to the parser.

@vjik vjik merged commit 789523f into master Apr 12, 2024
170 of 171 checks passed
@vjik vjik deleted the fix-update-with-expressions branch April 12, 2024 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:code review The pull request needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants