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

JDBC3DatabaseMetaData::getColumns doesn't correctly parse DECIMAL / NUMERIC precision, scale, if there is whitespace in the declaration #1215

Closed
lukaseder opened this issue Dec 5, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@lukaseder
Copy link

To Reproduce

Try this:

try (Statement s = connection.createStatement()) {
    try {
        s.executeUpdate("""
            create table t (
              n numeric (10, 5),
              d decimal (10, 5)
            )
            """);

        try (ResultSet rs = connection.getMetaData().getColumns(null, null, "t", "%")) {
            while (rs.next()) {
                System.out.println(rs.getString("COLUMN_NAME"));
                System.out.println(rs.getString("TYPE_NAME"));
                System.out.println(rs.getString("COLUMN_SIZE"));
                System.out.println(rs.getString("DECIMAL_DIGITS"));
                System.out.println();
            }
        }
    }
    finally {
        s.executeUpdate("drop table t");
    }
}

It prints:

n
NUMERIC
2000000000
10

d
DECIMAL
2000000000
10

If I omit the whitespace in the precision/scale declaration, like this:

create table t (   
  n numeric (10,5),
  d decimal (10,5) 
)                  

Then, at least the values are parsed, but the result is still incorrect:

n
NUMERIC
15
5

d
DECIMAL
15
5

Expected behavior

The output should be:

n
NUMERIC
10
5

d
DECIMAL
10
5

Environment (please complete the following information):

  • OS: Microsoft Windows [Version 10.0.22631.4460]
  • CPU architecture: x86_64
  • sqlite-jdbc version 3.46.1.0
@gotson gotson added bug Something isn't working and removed triage labels Dec 6, 2024
@gotson gotson closed this as completed in 8455468 Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants