Re: sql type reported for enum

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: rcohen(at)e1b(dot)org
Cc: "Hudson, Derrick" <dhudson(at)redcom(dot)com>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: sql type reported for enum
Date: 2015-08-19 19:27:49
Message-ID: CADK3HH+F6TeAiiAH5N2gOLb_WqUL0d_Zc3UjF0kDNn-5GvFu0w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Well seeing as there is no definition in the spec for this the behaviour is
up to us.

I don't recall the exact reason it was changed but it is likely to avoid
http://stackoverflow.com/questions/7603500/trying-to-map-postgres-enum-to-hibernate-jpa-pojo

what is the likelihood that dbunit will change their code if you file a bug
report ?

Dave Cramer

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

On 19 August 2015 at 14:16, <rcohen(at)e1b(dot)org> wrote:

> It breaks the jdbc meta-data; that is for an enum column
>
> columnsResultSet.*getInt*("DATA_TYPE")
>
> now returns Types.VARCHAR.
>
> This breaks some of my code; it also breaks DBUnit's support for
> postgres. Now
> I can code around this, but should the metadata be reporting that an enum
> column
> is of type Types.VARCHAR? This seems like incorrect behavior.
>
> Yes, enums should probably be avoided, but that isn't an option for me
> right now.
>
> Ross
>
>
>
> From: Dave Cramer <pg(at)fastcrypt(dot)com>
> To: "Hudson, Derrick" <dhudson(at)redcom(dot)com>,
> Cc: "rcohen(at)e1b(dot)org" <rcohen(at)e1b(dot)org>, "pgsql-jdbc(at)postgresql(dot)org"
> <pgsql-jdbc(at)postgresql(dot)org>
> Date: 08/19/2015 09:18 AM
> Subject: Re: [JDBC] sql type reported for enum
> Sent by: davecramer(at)gmail(dot)com
> ------------------------------
>
>
>
> 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*
> <https://milton1.wnyric.org/canit/urlproxy.php?_q=aHR0cDovL3d3dy5jcmVkYXRpdi5jYQ%3D%3D>
>
> On 19 August 2015 at 09:11, Hudson, Derrick <*dhudson(at)redcom(dot)com*
> <dhudson(at)redcom(dot)com>> wrote:
> There is the following change, which may be related:
>
>
> *https://jdbc.postgresql.org/documentation/changelog.html#version_9.2-1003*
> <https://milton1.wnyric.org/canit/urlproxy.php?_q=aHR0cHM6Ly9qZGJjLnBvc3RncmVzcWwub3JnL2RvY3VtZW50YXRpb24vY2hhbmdlbG9nLmh0bWwjdmVyc2lvbl85LjItMTAwMw%3D%3D>
>
> 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(at)postgresql(dot)org* <pgsql-jdbc-owner(at)postgresql(dot)org>
> [*pgsql-jdbc-owner(at)postgresql(dot)org* <pgsql-jdbc-owner(at)postgresql(dot)org>] On
> Behalf Of *rcohen(at)e1b(dot)org* <rcohen(at)e1b(dot)org> [*rcohen(at)e1b(dot)org*
> <rcohen(at)e1b(dot)org>]
> Sent: Tuesday, August 18, 2015 5:21 PM
> To: *pgsql-jdbc(at)postgresql(dot)org* <pgsql-jdbc(at)postgresql(dot)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(at)postgresql(dot)org*
> <pgsql-jdbc(at)postgresql(dot)org>)
> To make changes to your subscription:
> *http://www.postgresql.org/mailpref/pgsql-jdbc*
> <https://milton1.wnyric.org/canit/urlproxy.php?_q=aHR0cDovL3d3dy5wb3N0Z3Jlc3FsLm9yZy9tYWlscHJlZi9wZ3NxbC1qZGJj>
>
> ------------------------------
>
> *Spam*
> <https://milton1.wnyric.org/canit/b.php?i=01P6BiLXv&m=52a515939932&t=20150819&c=s>
> *Not spam*
> <https://milton1.wnyric.org/canit/b.php?i=01P6BiLXv&m=52a515939932&t=20150819&c=n>
> *Forget previous vote*
> <https://milton1.wnyric.org/canit/b.php?i=01P6BiLXv&m=52a515939932&t=20150819&c=f>
>
>
> ------------------------------
>
>
> * Confidentiality Notice: This electronic message and any attachments may
> contain confidential or privileged information, and is intended only for
> the individual or entity identified above as the addressee. If you are not
> the addressee (or the employee or agent responsible to deliver it to the
> addressee), or if this message has been addressed to you in error, you are
> hereby notified that you may not copy, forward, disclose or use any part of
> this message or any attachments. Please notify the sender immediately by
> return e-mail or telephone and delete this message from your system.*
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message dmp 2015-08-20 00:40:16 Re: sql type reported for enum
Previous Message Tom Smith 2015-08-19 19:20:57 best way to convert JSONB object from result