Skip to content

Conversation

Copy link

Copilot AI commented Sep 11, 2025

This PR adds comprehensive test coverage for the EXISTS/NOT EXISTS subquery functionality that was already implemented in Red ORM but not thoroughly tested.

Background

Issue #578 requested the ability to use EXISTS/NOT EXISTS as subqueries in Red ORM. The functionality was already implemented via the exists, is-empty, and manual Red::AST::Function approaches, but lacked proper test coverage to ensure it works as expected.

Changes

  • Added t/89-exists-subquery.rakutest with comprehensive test coverage for:
    • .exists method generating correct SQL with EXISTS clauses
    • .exists.not method generating correct SQL with NOT EXISTS clauses
    • .is-empty method (equivalent to .exists.not)
    • Manual Red::AST::Function approach with NOT EXISTS
    • Complex queries combining EXISTS checks with other conditions

Functionality Confirmed

All approaches mentioned in the original issue now work correctly:

# Recommended approach my $last = StatsViewRefresh.^rs.max(*.refresh-time); my $exists-not = StatsViewRefresh.^rs.exists.not; Upload.^all.grep( -> $v { $exists-not OR $v.uploaded > $last }).so; # Alternative approaches also work StatsViewRefresh.^rs.is-empty Red::AST::Function.new(args => [StatsViewRefresh.^rs.map(*.id).ast], func => 'NOT EXISTS')

These generate proper SQL with EXISTS/NOT EXISTS clauses as requested.

Fixes #578.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 360.zef.pm
    • Triggering command: curl --silent -L -z /home/REDACTED/.zef/store/360.zef.pm -o /home/REDACTED/.zef/store/360.zef.pm REDACTED (dns block)
    • Triggering command: wget -P /home/REDACTED/.zef/store --quiet REDACTED -O /home/REDACTED/.zef/store/360.zef.pm (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 3 commits September 11, 2025 02:12
…ady implemented Co-authored-by: FCO <99834+FCO@users.noreply.github.com>
Co-authored-by: FCO <99834+FCO@users.noreply.github.com>
…onality Co-authored-by: FCO <99834+FCO@users.noreply.github.com>
Copilot AI changed the title [WIP] EXISTS/NOT EXISTS as sub query Add comprehensive test coverage for EXISTS/NOT EXISTS subquery functionality Sep 11, 2025
Copilot AI requested a review from FCO September 11, 2025 02:20
Copilot finished work on behalf of FCO September 11, 2025 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants