Marc,
>> Whis in incorrect.
> Well, I'd have liked it if the = NULL had become IS NULL, but
> otherwise it looks pretty OK to me...
.... NULLs are to be considered equal in the ordering, and that NULLs should
sort either above or below all non-NULL values
[source:
http://troels.arvin.dk/db/rdbms/#select-order_by]
Using IS NULL or null comparison violates this since it returns same order
in case of ascending and descending comparison
and thus produces result which does not depend on comparion type.
MSSQL considers nulls lower than any other value. So for expression
c1<v1 or c2<=v2
should be changed somehow to check for nulls and assume that null is lower
than any other value.
This makes expression complicated. So instead of this maybe I should to
change null values to
-infinity, "", MinDate, boolean constants.
>> Should I create some pre-processor whcih replaces null values with those
>> fake values or try to create some other expression ?
> This may be a daft question, but why not simply put zero/false/
> DateTime.MinValue in your original tuple? If you want to compare to
> zero, ask it about zero... note also that your db's zero datetime may
> not be the same as .NET's zero datetime.
Is is not possible to use MinValue instead of null is DateRime is foreign
key reference.
null is used to represent unknown values it is not reasonable to change it
to MinDate.
>> B. NULL values in database columns.
>> Column values can also be nulls and cause incorrect result returned.
> I'd argue that the right results are being returned, under the SQL
> rules for NULL. It is like you are asking it about bananas and then
> complaining when it doesn't return pears... (IMO).
null values must sorted before any other values. I expect thatin descending
order they must be after other values then.
Comparing to null returns always null, so it produces same result for both
ascending and descending comparison. So it is probably incorrect.
Andrus.