>
> Personally, I think using straight String comparisons is the main
>> problem.  If you look at the code for Identifier#equals that is really
>> exactly what we need already.
>>
>> We cannot just drop the quotes for an accurate comparison.  "`MY_TABLE`"
>> and "`my_table`" are different tables to each sane and SQL spec compliant
>> database.  But conversely "MY_TABLE" and "my_table" are the same table.
>>
>
> That's true, so if one or both names are quoted, we can remove the quoting
> chars and do a case-sensitive comparison otherwise we we can do a
> case-insensitive comparison, am I right?
>

Correct.  That is more or less what Identifier#equals does, although atm in
the interest of simplicity it simply leverages the
Identifier#getCanonicalName of the 2 Identifiers to perform the
comparison.  Identifier#getCanonicalName lowercases the name if not quoted,
and then #equals compares that return.

We should really adjust this however as it can lead to false positive
hits.  Consider comparing "`my_table`" and "my_table" which really ought to
evaluate to not-equal[1].  However the canonical name in both cases is the
same ("my_table") and so would evaluate to equal.

[1] I believe this is database dependent - whether a quoted and non-quoted
identifier can ever refer to the same database/schema object.
_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to