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

Incorrect column metadata returned by ResultSetMetaData#isNullable for columns that contain null values filled from a left join #2079

Closed
jie-d opened this issue Mar 2, 2021 · 3 comments

Comments

@jie-d
Copy link

jie-d commented Mar 2, 2021

Describe the issue
ResultSetMetaData#isNullable returns ResultSetMetaData.columnNoNulls for columns that contain null values filled from a left join.
We had previously filed this bug when we first discovered the issue however that did not lead anywhere. We are able to provide an easier repro this time, see To Reproduce below.

Driver Version?
42.2.14

Java Version?
8.0.275.open

OS Version?
Windows 10

PostgreSQL Version?
12.5

To Reproduce
Create table schedules that contains a NOT NULL integer-type column schedule_id:

CREATE TABLE schedules (
    schedule_id         integer NOT NULL
);

Info on the actual data of schedule_id:
All values of column schedule_id stored in the table schedules are positive integers.

Execute query:

SELECT
         *
FROM (
        SELECT
            -1              s_id 
        ) s
        LEFT JOIN schedules
           ON s_id = schedule_id

Result of the query:

----------------------------
s_id       |    schedule_id
 -1        |       Null
----------------------------

Expected behavior
Calling ResultSetMetaData#isNullable on the object returned from PreparedStatement#getMetadata or Statement#executeQuery#getMetaData for this query suggests that the column schedule_id is nullable given that the column can be filled with null values from the left join.

Actual behavior
ResultSetMetaData#isNullable returns ResultSetMetaData.columnNoNulls in the above case.

@jie-d jie-d changed the title Incorrect column metadata returned by ResultSetMetaData#isNullable for columns that contain null values filled from a left join Incorrect column metadata returned by ResultSetMetaData#isNullable for columns that contain null values filled from a left join Mar 2, 2021
@davecramer
Copy link
Member

Unfortunately we don't get this information from the backend so it's impossible to fix.

@jie-d
Copy link
Author

jie-d commented Mar 3, 2021

Hi Dave, can you elaborate a bit on the info needed from the backend here? Thanks!

@davecramer
Copy link
Member

we see the table metadata not the result set metadata. So we think it is not nullable

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

No branches or pull requests

2 participants