Closed giuliohome closed 4 years ago
Found a workaround for the error 1 of 3 (i.e.: key END
is attached to the key WHERE
).
query {
for c in context.OilPhysical.EndurCost do
join n in context.OilPhysical.EndurNominationValid
on ( (c.DealNumber, c.CargoId, c.DeliveryId) =
((if (n.DeliveryDealNumber>0) then
n.DeliveryDealNumber
else n.ReceiptDealNumber),
n.CargoId, n.DeliveryId) )
where (c.BookingCompany = book &&
c.FeeStatus <> Cost.ClosedFeeStatus &&
c.FeeType <> delete_type &&
( c.CounterpartyId = i_str ||
c.FeeId = i || c.CargoId = i )
)
take 90
select c
}
but errors 2 and 3 (i.e.: [c].[ReceiptDealNumber]
sohuld be [n].[ReceiptDealNumber]
) do persist
Found a working workaround also for erros 2 and 3! I've moved the difficult part of the join on
condition into the where
condition.
query {
for c in context.OilPhysical.EndurCost do
join n in context.OilPhysical.EndurNominationValid
on ( (c.CargoId, c.DeliveryId) =
(n.CargoId, n.DeliveryId) )
where (c.BookingCompany = book &&
(n.DeliveryDealNumber = c.DealNumber || n.ReceiptDealNumber = c.DealNumber) &&
c.FeeStatus <> Cost.ClosedFeeStatus &&
c.FeeType <> delete_type &&
( c.CounterpartyId = i_str ||
c.FeeId = i || c.CargoId = i )
)
take 90
select c
Now the issue is normal priority, no longer super urgent ;-)
Failing SQL wouldn't be so bad, but generating incorrect SQL is always quite urgent priority, even if it's a bit of an edge-case. The PR should fix it, I have to do bit more testing to not break backward compatibility though.
If you have the environment in place, it would be nice if you can verify the initial query also works with the latest version (1.1.68).
Great! Your support is really appreciated, thank you very much, will test the latest version soon in my environment.
Awesome! Issue resolved! Thank so much again!
Description
I'm trying to fix an issue in my project and I need to avoid duplicate records with a more advanced join condition.
Repro steps
I've activated the sql logging (and I'm testing my library via f# interactive) against the effective db where the issue has been originated.
The problem is that there are 3 errors in the generated SQL
the key
END
is attached to the keyWHERE
([c].[DeliveryDealNumber] > 0)
should be([n].[DeliveryDealNumber] > 0)
ELSE [c].[ReceiptDealNumber]
sohuld beELSE [n].[ReceiptDealNumber]
Expected behavior
Correct sql and no exception.
Actual behavior
There is an exception
Known workarounds
At the moment I'm not aware of any known workarounds and this is urgent.
Related information