FCO / Red

A WiP ORM for Raku
Artistic License 2.0
68 stars 27 forks source link

X metaop #403

Open FCO opened 4 years ago

FCO commented 4 years ago
(Model1.^all X Model2.^all).grep: { .[0].col1 == .[1].col2 }

should it do something like this?

SELECT
   table1.*, table2.*
FROM
   table1 as t1
   JOIN table2 as t2 ON t1.col1 = t2.col2
FCO commented 4 years ago

maybe it could be the solution for #345

mattlaw commented 4 years ago

Looks like a good solution for inner joins, but tricky to extend to outer joins.

my ($left, $right) = [1, 2, 3], [1, 2, 4];
$left.map: -> $lv { |( $lv X ($right.grep( -> $rv {$lv == $rv}) || (Nil)) ) }

--> ((1 1) (2 2) (3 Nil))

Xliff commented 4 years ago

For some DBOs this might be better off as a CROSS JOIN.

https://www.w3resource.com/sql/joins/cross-join.php

So that:

   (Model1.^all X Model2.^all)

results in:

SELECT *
FROM Model1
CROSS JOIN Model2

That is the best match for the X metaop, BTW.