Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4f63a0e

Browse files
committed
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
1 parent 6e63468 commit 4f63a0e

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/interfaces/jdbc/org/postgresql/jdbc1/ResultSetMetaData.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,22 @@ public boolean isCurrency(int column) throws SQLException
136136
}
137137

138138
/**
139-
* Can you put a NULL in this column? I think this is always
140-
* true in 6.1's case. It would only be false if the field had
141-
* been defined NOT NULL (system catalogs could be queried?)
139+
* Indicates the nullability of values in the designated column.
142140
*
143141
* @param column the first column is 1, the second is 2...
144142
* @return one of the columnNullable values
145143
* @exception SQLException if a database access error occurs
146144
*/
147145
public int isNullable(int column) throws SQLException
148146
{
149-
return columnNullable; // We can always put NULL in
147+
/*
148+
* TODO This needs a real implementation, taking into account columns
149+
* defined with NOT NULL or PRIMARY KEY, CHECK constraints, views,
150+
* functions etc.
151+
*/
152+
return columnNullableUnknown;
150153
}
151-
154+
152155
/**
153156
* Is the column a signed number? In PostgreSQL, all numbers
154157
* are signed, so this is trivial. However, strings are not

src/interfaces/jdbc/org/postgresql/jdbc2/ResultSetMetaData.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,20 @@ public boolean isCurrency(int column) throws SQLException
131131
}
132132

133133
/**
134-
* Can you put a NULL in this column? I think this is always
135-
* true in 6.1's case. It would only be false if the field had
136-
* been defined NOT NULL (system catalogs could be queried?)
134+
* Indicates the nullability of values in the designated column.
137135
*
138136
* @param column the first column is 1, the second is 2...
139137
* @return one of the columnNullable values
140138
* @exception SQLException if a database access error occurs
141139
*/
142140
public int isNullable(int column) throws SQLException
143141
{
144-
return columnNullable; // We can always put NULL in
142+
/*
143+
* TODO This needs a real implementation, taking into account columns
144+
* defined with NOT NULL or PRIMARY KEY, CHECK constraints, views,
145+
* functions etc.
146+
*/
147+
return columnNullableUnknown;
145148
}
146149

147150
/**

0 commit comments

Comments
 (0)