Skip to content

Incorrect result of isNullable for constant values #144

@mwisnicki

Description

@mwisnicki

isNullable for SELECT 1 returns 1 (columnNullable) instead of 0 (columnNoNulls) or 2 (columnNullableUnknown).

//DEPS com.amazon.redshift:redshift-jdbc42:2.1.0.34

import java.sql.*;

public class RedshiftDemo {
    private static final String DB_URL = System.getenv("REDSHIFT_URL");
    private static final String DB_USER = System.getenv("REDSHIFT_USER");
    private static final String DB_PASSWORD = System.getenv("REDSHIFT_PASSWORD");

    public static void main(String[] args) throws Exception {
        try (Connection conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
             Statement stmt = conn.createStatement();
             ResultSet rs = stmt.executeQuery("SELECT 1, 'hi'")) {

            System.out.println("Nullable[1]:" + rs.getMetaData().isNullable(1));
            System.out.println("Nullable[2]:" + rs.getMetaData().isNullable(2));
            rs.next();
            System.out.printf("Query result: %s %s%n", rs.getInt(1), rs.getObject(2));
        }
    }
}
Nullable[1]:1
Nullable[2]:1
Query result: 1 hi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions