Hi,
> > I see two reasons why this is not appropriate:
> > 1) unclear why to convert 'a' to int rather then 1 to varchar
>
> Correct, and because it's unclear it should throw an error.
Well, the exception is thrown because 'a' cannot be converted to 1,
not because it's unclear. If it was for ambiguity reason it should
read something like "Incompatible data types in expression: 1='a' "
and it should have been thrown also for 1='1'.
In my opinion if data types don't match then the expression should
return false for both 1='a' and 1='1' without throwing an error. This
would be more intuitive for Java developers who are used to the
contract of equal() method.
>From the other hand I agree that current convention is practical since
it saves typing to invoke conversion explicitly: 1=cast('1', int) or
cast(1, varchar)='1'
> > 2) other databases (I checked mysql) run such a statement without
> > error
>
> That is the only one which accepts that.
> All others I have tested (Postgres, Oracle, SQL Server, Firebird, DB2)
> throw an error message.
Thanks. I did not check. Then maybe a better way would be to throw an
error if compatibility mode is set on.
Nevertheless I still hope that reasoning presented above could
overweight the benefit of somewhat flawed commonality.
> What is even more critical with MySQL that it tries to guess what you
> mean when doing implicit conversion.
Yes, this is weird in MySql.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---