Commit 4f63a0e1 authored by Bruce Momjian's avatar Bruce Momjian

Attached is a patch that fixes ResultSetMetaData.isNullable() in

the JDBC driver.

This method is currently unimplemented and always returns
ResultSetMetaData.columnNullable. This is obviously incorrect
when a column is defined with NOT NULL or PRIMARY KEY. And we
have to think of check constraints, views, functions etc.

The patch simply changes the return value to
ResultSetMetaData.columnNullableUnknown. This is until someone
comes up with a real implementation of course.

On Fri, 14 Sep 2001 17:53:50 +0200, Tomisaw Kity?ski wrote:
>Hello there,
>
>could someone tell me, please, do I have any chance to get
>proper implementation of above method in JDBC (1.1+) soon?
>
>Current "return 1" works fine on most tables, however it seems
>to be a little bit incorrect with some of them ;)

Ren? Pijlman
parent 6e63468f
...@@ -136,9 +136,7 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData ...@@ -136,9 +136,7 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
} }
/** /**
* Can you put a NULL in this column? I think this is always * Indicates the nullability of values in the designated column.
* true in 6.1's case. It would only be false if the field had
* been defined NOT NULL (system catalogs could be queried?)
* *
* @param column the first column is 1, the second is 2... * @param column the first column is 1, the second is 2...
* @return one of the columnNullable values * @return one of the columnNullable values
...@@ -146,7 +144,12 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData ...@@ -146,7 +144,12 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
*/ */
public int isNullable(int column) throws SQLException public int isNullable(int column) throws SQLException
{ {
return columnNullable; // We can always put NULL in /*
* TODO This needs a real implementation, taking into account columns
* defined with NOT NULL or PRIMARY KEY, CHECK constraints, views,
* functions etc.
*/
return columnNullableUnknown;
} }
/** /**
......
...@@ -131,9 +131,7 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData ...@@ -131,9 +131,7 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
} }
/** /**
* Can you put a NULL in this column? I think this is always * Indicates the nullability of values in the designated column.
* true in 6.1's case. It would only be false if the field had
* been defined NOT NULL (system catalogs could be queried?)
* *
* @param column the first column is 1, the second is 2... * @param column the first column is 1, the second is 2...
* @return one of the columnNullable values * @return one of the columnNullable values
...@@ -141,7 +139,12 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData ...@@ -141,7 +139,12 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
*/ */
public int isNullable(int column) throws SQLException public int isNullable(int column) throws SQLException
{ {
return columnNullable; // We can always put NULL in /*
* TODO This needs a real implementation, taking into account columns
* defined with NOT NULL or PRIMARY KEY, CHECK constraints, views,
* functions etc.
*/
return columnNullableUnknown;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment