Project

Profile

Help

Bug #6215

closed

SQL extension: returning the results of a join query

Added by Michael Kay 7 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Saxon extensions
Sprint/Milestone:
-
Start date:
2023-10-06
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
Java

Description

The data returned from a call on SQL extensions using a join query between two tables with common column names appears to be incomplete: see https://stackoverflow.com/questions/77243137

Actions #1

Updated by Michael Kay 6 months ago

  • Status changed from New to In Progress

Sorry about the delay. I have finally got around to re-establishing a test environment where I can debug this.

First thing is, I've established that (at least with PostgresSQL), with a query of the form

SELECT date AS date2, price AS price2 FROM book WHERE author = ?'

the current code (which calls resultSetMetaData.getColumnName()) is in fact using "date2" and "price2" as the column labels. Using resultSetMetaData.getColumnLabel() gives exactly the same result.

Actions #2

Updated by Michael Kay 6 months ago

Next experiment, if I give both columns the same AS name, it doesn't complain and just returns a map in which one of the fields (the first one) is missing (because of course the duplicate name has overridden it).

Actions #3

Updated by Len Schultz 6 months ago

I noticed the same thing with MySQL. With one table or joins of unique tables with unique column names, I can use AS to rename a column.

Actions #4

Updated by Michael Kay 6 months ago

  • Status changed from In Progress to Resolved
  • Applies to branch 12, trunk added
  • Fix Committed on Branch 12, trunk added

I have added some test cases that establish the "AS" column name is used when available; and I have changed the code so that a unique key name is generated in the result map if the supplied column names are not unique.

Actions #6

Updated by O'Neil Delpratt 5 months ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 12.4 added

Bug fix applied in the Saxon 12.4 maintenance release

Please register to edit this issue

Also available in: Atom PDF