Apache OpenOffice (AOO) Bugzilla – Full Text Issue Listing |
Summary: | Query designer does not include table alias in ORDER BY clause | ||||||
---|---|---|---|---|---|---|---|
Product: | Base | Reporter: | ptoye <oo> | ||||
Component: | code | Assignee: | AOO issues mailing list <issues> | ||||
Status: | CONFIRMED --- | QA Contact: | |||||
Severity: | Trivial | ||||||
Priority: | P3 | CC: | drewjensen.inbox, issues | ||||
Version: | OOo 3.0 | ||||||
Target Milestone: | --- | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Issue Type: | DEFECT | Latest Confirmation in: | --- | ||||
Developer Difficulty: | --- | ||||||
Attachments: |
|
Description
ptoye
2009-01-11 16:32:56 UTC
Created attachment 59296 [details]
Test database
@ptoye - Actually the query, "Test wrong", in the bug doc is not giving erroneous results. A column used in an ORDER BY clause does not have to be part of the result set. Meaning that if an alias is created to match an existing column name in a query, and if these two identifiers can be found in multiple tables in that query, then the SQL should include the table alias in the ORDER BY clause in order to remove ambiguity. If this is not done then the parser (HSQLdb parser here) will select a suitable candidate and in this particular case that selection is not the one you wanted. OK - look at the query again: SELECT "MainTable"."Id", "Rooms"."Collation" AS "LCollation", "Rooms_1"."Collation" AS "Collation" FROM "MainTable" AS "MainTable", "Rooms" AS "Rooms", "Rooms" AS "Rooms_1" WHERE "MainTable"."List location" = "Rooms"."ID" AND "MainTable"."Location" = "Rooms_1"."ID" ORDER BY "Collation" ASC From the perspective of the query parser there are two candidates for this ORDER BY clause, Room.Collation and Room_1.Collation. The proper way to clear that up then would be to tell it which to use: ORDER BY "Room_1"."Collation" ASC The real problem here, IMO, is the fact that the Query Designer does not include the table name(alias) in the ORDER By clause - Checked this with both OO.o 3.0.1 RC1 and DEV300_m37. Changing the summary line from: Query gives wrong result when alias names clash with field names to: Query designer does not include table alias in ORDER BY clause assign to developer The column name used in the order by is unique and it should be 3rd one in this example. MySQL does it this way and the developer from HsqlDB says the same. So it is an issue in the hsqldb engine. |