dbeaver / dbeaver

Free universal database tool and SQL client
https://dbeaver.io
Apache License 2.0
40.72k stars 3.51k forks source link

Composite types are handled incorrectly (the solution is presented) #36415

Open ask9 opened 2 days ago

ask9 commented 2 days ago

Description

https://github.com/user-attachments/assets/6eb2ce3c-1024-495b-9024-68444127503b

Actual query:

SELECT "f.title", COUNT(*) FROM (
select f
from film as f
) src
GROUP BY "f.title"

Expected query:

SELECT (src.f).title, COUNT(*)
FROM (
    select f
    from film as f
) src
GROUP BY (src.f).title

DBeaver Version

Enterprise Edition 24.3.0-202411230022

Operating System

Windows 10

Database and driver

PostgreSQL 16 PostgreSQL JDBC Driver 42.7.4

Steps to reproduce

No response

Additional context

No response

ask9 commented 2 days ago

The similar issue appears with Filter by value:

https://github.com/user-attachments/assets/eb939b99-9049-44c5-8d28-06ca0ff8a7f8

Actual query:

SELECT * FROM (
select f
from film as f

) z_q WHERE f.title IN ('Grosse Wonderful')

Expected query:

SELECT *
FROM (
    select f
    from film as f
) z_q
WHERE (z_q.f).title IN ('Grosse Wonderful')
ask9 commented 2 days ago

If you have automated tests, I suggest adding additional test case for queries with composite types for all existing features.

E1izabeth commented 10 hours ago

Thanks for the bug report

E1izabeth commented 10 hours ago

Also if I put the cursor on Filter option in the context menu, I get exception image

java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
    at org.jkiss.dbeaver.model.impl.jdbc.data.JDBCCollection.makeArrayString(JDBCCollection.java:147)
    at org.jkiss.dbeaver.model.impl.jdbc.data.JDBCCollection.toString(JDBCCollection.java:128)
    at org.jkiss.dbeaver.model.impl.data.formatters.NumberDataFormatter.formatValue(NumberDataFormatter.java:143)
    at org.jkiss.dbeaver.model.impl.jdbc.data.handlers.JDBCNumberValueHandler.getValueDisplayString(JDBCNumberValueHandler.java:85)
    at org.jkiss.dbeaver.ui.controls.resultset.FilterByAttributeAction.translateFilterPattern(FilterByAttributeAction.java:64)
    at org.jkiss.dbeaver.ui.controls.resultset.FilterByAttributeAction.<init>(FilterByAttributeAction.java:36)
    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer.fillFiltersMenu(ResultSetViewer.java:3453)
    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer.lambda$fillContextMenu$24(ResultSetViewer.java:2799)
    at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:338)
    at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:467)