jinaga / jinaga.net

.NET immutable data management library
MIT License
14 stars 3 forks source link

Labels not appearing in the projection do not contribute to the pipeline #9

Closed michaellperry closed 2 years ago

michaellperry commented 3 years ago

Compare the pipelines of these two specifications:

var compoundSpecification = Given<Airline>.Match((airline, facts) =>
    from flight in facts.OfType<Flight>()
    where flight.airlineDay.airline == airline
    from booking in facts.OfType<Booking>()
    where booking.flight == flight
    from cancellation in facts.OfType<FlightCancellation>()
    where cancellation.flight == flight
    select new
    {
        booking,
        cancellation
    }
);

var simpleSpecification = Given<Airline>.Match((airline, facts) =>
    from flight in facts.OfType<Flight>()
    where flight.airlineDay.airline == airline
    from booking in facts.OfType<Booking>()
    where booking.flight == flight
    from cancellation in facts.OfType<FlightCancellation>()
    where cancellation.flight == flight
    select cancellation
);

They produce different pipelines:

simpleSpecification.Pipeline.ToDescriptiveString()
airline: Skylane.Airline {
    flight: Skylane.Flight = airline S.airline Skylane.Airline.Day S.airlineDay Skylane.Flight
    cancellation: Skylane.Flight.Cancellation = flight S.flight Skylane.Flight.Cancellation
}

compoundSpecification.Pipeline.ToDescriptiveString()
airline: Skylane.Airline {
    flight: Skylane.Flight = airline S.airline Skylane.Airline.Day S.airlineDay Skylane.Flight
    booking: Skylane.Booking = flight S.flight Skylane.Booking
    cancellation: Skylane.Flight.Cancellation = flight S.flight Skylane.Flight.Cancellation
}

The pipeline -- and therefore the number of results -- should not change based on which facts are selected.

michaellperry commented 2 years ago

The pipeline is now generated based only on the set definitions, not the projection. Both specifications yield the full pipeline:

airline: Skylane.Airline {
    flight: Skylane.Flight = airline S.airline Skylane.Airline.Day S.airlineDay Skylane.Flight
    booking: Skylane.Booking = flight S.flight Skylane.Booking
    cancellation: Skylane.Flight.Cancellation = flight S.flight Skylane.Flight.Cancellation
}
michaellperry commented 2 years ago

Released: https://github.com/jinaga/jinaga.net/releases/tag/v0.2.21