Thread: Issue with DataBaseMetaData.GetTypeInfo()
Hello list! I am using the postgresql-8.3-603.jdbc4.jar JDBC driver. My problem is that DataBaseMetadata.GetTypeInfo() does not return correct information in the columns LITERAL_PREFIX and LITERAL_SUFFIX. It returns null for all data types, but for character data types it should return the single quote character. You can easily verify this by running DBVisualizer and look at the 'Data Types' tab for the database connection. I downloaded the source code from cvs and fixed the problem. How can I contribute this to the community? Cheers, Mats Ekelund
Mats Ekelund wrote: > > I downloaded the source code from cvs and fixed the problem. How can I > contribute this to the community? > Send us the output from "cvs diff -c > mychanges.patch". Kris Jurka
Mats Ekelund wrote: > > I have attached the patch. Please keep the mailing list CCed so all can see/participate in the discussion. + else if ( typname.equals("varchar") || typname.equals("char") || typname.equals("text") || + typname.equals("name") || typname.equals("timestamp") || typname.equals("timestamptz") ) + { + tuple[3] = connection.encodeString("'"); + tuple[4] = connection.encodeString("'"); + } Your patch hard codes this for a couple of types, but it doesn't seem to be a general solution. It seems impossible to enumerate all the possible types that require quoting. What about any user defined types, we can't possible know what those are in the driver? If you were going to hardcode a list, you need to hardcode the list of types that don't require quoting because that should at least be a fixed list. A more general solution would be to put this information into TypeInfoCache so you could say something like TypeInfoCache.requiresQuoting(typeOid). Kris Jurka
Here is a more general solution: the mapping is done for SQL types since it should be a fixed number of types. Mats Ekelund 2008/3/31, Kris Jurka <books@ejurka.com>: > Mats Ekelund wrote: > > > > I have attached the patch. > > > > Please keep the mailing list CCed so all can see/participate in the > discussion. > > + else if ( typname.equals("varchar") || typname.equals("char") > || typname.equals("text") || > + typname.equals("name") || typname.equals("timestamp") > || typname.equals("timestamptz") ) > + { > + tuple[3] = connection.encodeString("'"); > + tuple[4] = connection.encodeString("'"); > + } > > > Your patch hard codes this for a couple of types, but it doesn't seem to be > a general solution. It seems impossible to enumerate all the possible types > that require quoting. What about any user defined types, we can't possible > know what those are in the driver? > > If you were going to hardcode a list, you need to hardcode the list of types > that don't require quoting because that should at least be a fixed list. A > more general solution would be to put this information into TypeInfoCache so > you could say something like > TypeInfoCache.requiresQuoting(typeOid). > > Kris Jurka >
Attachment
On Mon, 7 Apr 2008, Mats Ekelund wrote: > Here is a more general solution: the mapping is done for SQL types > since it should be a fixed number of types. > I've applied a modified version of this patch to CVS. Kris Jurka