alf-tool / alf-core

Core classes, the kernel of Alf
MIT License
50 stars 5 forks source link

restrict with empty relation comparison #6

Open eregon opened 10 years ago

eregon commented 10 years ago

With this query (ran with alf --examples show):

parts, shipments, suppliers = [parts(), supplies(), suppliers()].map(&:to_relation)
suplondon = suppliers.restrict(city: 'NOTLondon')[:sid]
supplied_by = parts[:pid].image(shipments[:pid,:sid].matching(suplondon), :sups)
p a == b
puts supplied_by
puts suplondon
supplied_by.restrict(sups: suplondon)[:pid]

If I am not mistaken, the results should be all parts, from P1 to P6. And even though we see for P1, == yields true, the restrict seems to remove it.

blambeau commented 10 years ago

Quick type inference for the record:

suplondon: Relation[sid]
supplied_by: Relation[pid, sups: Relation[sid]]

Indeed, the comparison make sense (no type checking error). And the comparison should return true for every part.

Thanks for reporting, I'll have a look at what happens.