Menu

ResultSet sometimes return column names in uppcase

Igor
2016-07-19
2016-08-12
  • Igor

    Igor - 2016-07-19

    Hi All.
    I have CSV file sample.csv

    Name,x,y,Epsg
    1,33,55,epsg:4326
    2,-139.3322,55.4604,epsg:4326
    3,-105.1983,22.9552,epsg:4326
    

    When i execute select * from sample column names returned as they defined in CSV: Name, x, y, Epsg.
    But select Epsg from sample or select Epsg from sample group by Epsg returns column name in uppercase EPSG.

    ResultSet should returns column names in upper case or 'as is' always.

    Am i right?

     
  • Simon Chenery

    Simon Chenery - 2016-07-21

    You are correct.

    CsvJdbc should return column names 'as is' for consistency, and not convert column names to uppercase.

    CsvJdbc is case-insensitive, so "id", "Id" and "ID" all refer to the same column, so this inconsistency is usually no problem.

     
  • Igor

    Igor - 2016-07-22

    Hi Simon.

    Thanks for you response.

    For example i have an application server that works with different databases uniformly via jdbc. The same code of application server works with different datasources.
    To fix the problem, data access layer, should:
    * iteract with datasources in uppcase
    * convert resultset column names to uppercase.
    But it's a real headache because Oracle, Postgre, ... are case sensitive, and convertion to upper case can't solve the problem.

     
  • Simon Chenery

    Simon Chenery - 2016-07-22

    Logged as CsvJdbc bug #125 Return column names in original case used in SQL query.

     
    • PAscal

      PAscal - 2016-07-25

      shouldn't the columns case be the one of the csv file header (not the one used in the query ) ?

       
  • Simon Chenery

    Simon Chenery - 2016-07-26

    @PAscal, your suggestion is more logical. I changed the bug description to state that column names should be the same case as in the csv file header.

     
    • PAscal

      PAscal - 2016-07-26

      Thank you Simon,
      It will be better for columns names.

      I'm not so sure about the behavior of Oracle, PostgreSQL or MySQL regarding "uncoted" Aliases names (and I'm too far from any computer to test it those days :-)

       
  • Will

    Will - 2016-08-04

    Simon,
    Is this issue (bug 125) something you think you'll be able to address soon? If not, are you open to pull requests? It's affecting some work that I'm doing and the workaround is tedious...

     
  • Simon Chenery

    Simon Chenery - 2016-08-04

    I will fix bug 125 and create a new release by 18.08.2016.

    I will also accept a git pull request (either here on SourceForge or on https://github.com/simoc/csvjdbc ), if you want to fix it sooner.

     
  • Igor

    Igor - 2016-08-08

    Hi
    Simon here my solution https://github.com/simoc/csvjdbc/pull/4

     
  • Simon Chenery

    Simon Chenery - 2016-08-11

    Bug 125 fixed and included in CsvJdbc version 1.0-31.

     
  • PAscal

    PAscal - 2016-08-11

    Thank you for this new release.

    Maybe this could also be applied to columns quoted alias
    as done in main other RDBMS:

    *** MySQL
    select 1 as One, 1 as "One"

    +-----+-----+
    | One | One |
    +-----+-----+
    | 1 | 1 |
    +-----+-----+

    *** PostgreSQL
    select 1 as One, 1 as "One"

    +-------------+-------------+
    | one | One |
    +-------------+-------------+
    | 1 | 1 |
    +-------------+-------------+

    *** Oracle
    select 1 as One, 1 as "One" from dual

    +------------------------+------------------------+
    | ONE | One |
    +------------------------+------------------------+
    | 1 | 1 |
    +------------------------+------------------------+

    *** CsvJdbc 1-0-31
    select 1 as One, 1 as "One" FROM tab

    +----------------------+----------------------+
    | ONE | ONE |
    +----------------------+----------------------+
    | 1 | 1 |
    +----------------------+----------------------+

     
    • Simon Chenery

      Simon Chenery - 2016-08-12

      Yes. This is CsvJdbc bug 126.

       

Log in to post a comment.