Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FBResultSetMetaData.getTableAlias return wrong alias in SQL where with CTE [JDBC513] #549

Closed
firebird-automations opened this issue Nov 6, 2017 · 5 comments

Comments

@firebird-automations
Copy link

Submitted by: Mark (mareczek55)

Duplicates CORE5655

When call getTableAlias() is called on a sql with CTE, wrong table alias is returned.
When sql is created, to the tableAlias is inserted alias with space and when "where" is added, exception is thrown because of space.
The final table alias is created by joining both table aliases (from common table expression and from select).

Here is a simple example:

create table tableA(
column1 varchar(20),
column2 varchar(20)
);

insert into tableA(column1, column2) values('test','some text');
insert into tableA(column1, column2) values('test2','some text2');
insert into tableA(column1, column2) values('test3','some text3');

with CTE as (SELECT column1 from TABLEA T)
select CT.column1 from CTE CT

SQL error code = -104
Token unknown - line 4, column 11
T
with CTE as ( select column1 from tableA T)
select CT.column1
from CTE CT
where (CT T.COLUMN1 starting 'test')

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

I can reproduce this. The method `getTableAlias` uses the alias information provided by Firebird (in information element isc_info_sql_relation_alias), so it is a bug in Firebird itself .

I will see if this has already been reported in the CORE project, or otherwise I'll create a ticket there.

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Reported this as CORE5655. Note that the problem is not limited to CTEs, it will do the same for nested table expressions like select * from (select column1 from tablea t) d

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Link: This issue duplicates CORE5655 [ CORE5655 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Closing as this needs to be fixed in Firebird itself.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Open [ 1 ] => Closed [ 6 ]

resolution: Duplicate [ 3 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants