Re: sql type reported for enum

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: sql type reported for enum
Дата
Msg-id CADK3HHJPE9+kKkbz5WGZPKhwh-pRSaOF=HT+1xU=jtiZTdN2hg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: sql type reported for enum  ("Hudson, Derrick" <dhudson@redcom.com>)
Ответы Re: sql type reported for enum  (rcohen@e1b.org)
Список pgsql-jdbc
So what does this break ?

FWIW, I avoid enum's for many reasons and use check constraints instead.

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On 19 August 2015 at 09:11, Hudson, Derrick <dhudson@redcom.com> wrote:
There is the following change, which may be related:

    https://jdbc.postgresql.org/documentation/changelog.html#version_9.2-1003

    Author: Tom Dunstan Date: Sun Jul 7 16:20:41 2013 +0930
    Make PreparedStatement.getObject() for an enum type return a string rather than a PGObject



________________________________________
From: pgsql-jdbc-owner@postgresql.org [pgsql-jdbc-owner@postgresql.org] On Behalf Of rcohen@e1b.org [rcohen@e1b.org]
Sent: Tuesday, August 18, 2015 5:21 PM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] sql type reported for enum

I have some metadata utilities that query jdbc column metadata,
and I'm fairly certain that my enum colums, which used to be reported at
Type.OTHER, are now being reported as Type.VARCHAR.

That is,
        rs.getInt("DATA_TYPE")
returns Type.OTHER

The type names, however, seem to be correct.  Thus,
        rs.getString("TYPE_NAME")
returns the actual enum name.

Not only does my code now behave differently, but I also
see that 3rd party libraries (DBUnit) are also now missing
enum columns.

Thus, DBUnit's PostgresqlDataTypeFactory code for returning enums never
gets hits because the sqlType is never Types.OTHER:

        if (sqlType == Types.OTHER)
            if ("uuid".equals(sqlTypeName))
                return new UuidType();
            else if ("interval".equals(sqlTypeName))
                    return new IntervalType();
            else if ("inet".equals(sqlTypeName))
                return new InetType();
            else
            {
                // Finally check whether the user defined a custom datatype
                if(isEnumType(sqlTypeName))
                {
                    if(logger.isDebugEnabled())
                    return new GenericEnumType(sqlTypeName);
                }
            }


So did something change recently in the drivers?   I've recently upgraded my database from
9.1 to 9.4, along with my jdbc drivers.

Thanks,
Ross


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Hudson, Derrick"
Дата:
Сообщение: Re: sql type reported for enum
Следующее
От: rcohen@e1b.org
Дата:
Сообщение: Re: sql type reported for enum