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

Adding support for NOT operator #185

Merged
merged 7 commits into from
Apr 4, 2024
Merged

Adding support for NOT operator #185

merged 7 commits into from
Apr 4, 2024

Conversation

msmakouz
Copy link
Member

@msmakouz msmakouz commented Apr 2, 2024

What's was changed

Support for the NOT operator in SQL queries has been added. To implement this functionality, new methods whereNot, andWhereNot, and orWhereNot have been added.

Examples:

$users = $database
    ->select('*')
    ->from('users')
    ->whereNot('status', 'blocked')
    ->fetchAll()

// SELECT * FROM `users` WHERE NOT `status` = 'blocked'
$users = $this->db()
    ->select('*')
    ->from('users')
    ->where('balance', '>', 0)
    ->andWhereNot('status', 'blocked')
    ->fetchAll();

// SELECT * FROM `users` WHERE `balance` > 0 AND NOT `status` = 'blocked'

Closes: #182

@msmakouz msmakouz added this to the 2.10.x milestone Apr 2, 2024
@msmakouz msmakouz requested a review from roxblnfk April 2, 2024 11:19
@msmakouz msmakouz self-assigned this Apr 2, 2024
Copy link

codecov bot commented Apr 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.32%. Comparing base (1f5b226) to head (f76b187).

❗ Current head f76b187 differs from pull request most recent head f1543f9. Consider uploading reports for the commit f1543f9 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x     #185      +/-   ##
============================================
+ Coverage     95.29%   95.32%   +0.03%     
- Complexity     1851     1856       +5     
============================================
  Files           130      130              
  Lines          5099     5136      +37     
============================================
+ Hits           4859     4896      +37     
  Misses          240      240              

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

Copy link
Member

@roxblnfk roxblnfk left a comment

Choose a reason for hiding this comment

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

Need to add tests

  • with arrays like

    $select->whereNot([
        '@or' => [
            [
                'id'   => ['between' => [10, 100]],
                'name' => 'Anton'
            ],
            ['status' => 'disabled']
        ]
    ]);
  • with sequence like ->whereNot()->where()->whereNot()->orWhere()->whereNot()

@msmakouz msmakouz force-pushed the feature/where-not branch from ddfb9de to 7604396 Compare April 3, 2024 13:42
@roxblnfk roxblnfk merged commit dafbe73 into 2.x Apr 4, 2024
38 of 40 checks passed
@roxblnfk roxblnfk deleted the feature/where-not branch April 4, 2024 19:36
roxblnfk added a commit that referenced this pull request Apr 4, 2024
…ods `whereNot`, `andWhereNot`, and `orWhereNot`

to the query builder by @msmakouz (#185)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

💡 Add support for NOT operator
2 participants