Cool, patch looks great Andrea.
Andrea Aime wrote:
> Justin Deoliveira ha scritto:
>> Hi Andrea,
>>
>> I think there may be a minor issue with the patch. Is there a patch to
>> look at? I am not sure of exactly the change you are proposing but i
>> think i ran up against this same issue. If you look at line 1269 on
>> JDBC1DataStore there is a comment explaining the problem. Basically it
>> boils down to how some of the feature readers and how they copy
>> features. Basically some of them just create a null array of attributes
>> and then set the objects one by one. However if the feature type says
>> that an attribute cannot be null that code will fail. So the workaround
>> was to setting minoccurs to > 0 if the attribute was indeed nillable.
>>
>> So I think the fix will be cool, but like you say I think we will have
>> to fix code in other places too in both geotools and geoserver.
>
> Yeah, the patch follows the directions in that comment (I hope).
> Here it is.
>
> ----------------------------------------------------------------------------------------
>
>
> Index:
> C:/progetti/geotools/trunk/modules/plugin/postgis/src/main/java/org/geotools/data/postgis/PostgisDataStore.java
>
> ===================================================================
> ---
> C:/progetti/geotools/trunk/modules/plugin/postgis/src/main/java/org/geotools/data/postgis/PostgisDataStore.java
> (revision 24721)
> +++
> C:/progetti/geotools/trunk/modules/plugin/postgis/src/main/java/org/geotools/data/postgis/PostgisDataStore.java
> (working copy)
> @@ -943,13 +943,31 @@
> final int TABLE_NAME = 3;
> final int COLUMN_NAME = 4;
> final int TYPE_NAME = 6;
> + final int NULLABLE = 11;
> String typeName = metadataRs.getString(TYPE_NAME);
> -
> +
> if (typeName.equals("geometry")) {
> String tableName = metadataRs.getString(TABLE_NAME);
> String columnName = metadataRs.getString(COLUMN_NAME);
> +
> + // check for nullability
> + int nullCode = metadataRs.getInt( NULLABLE );
> + boolean nillable = true;
> + switch( nullCode ) {
> + case DatabaseMetaData.columnNoNulls:
> + nillable = false;
> + break;
> +
> + case DatabaseMetaData.columnNullable:
> + nillable = true;
> + break;
> +
> + case DatabaseMetaData.columnNullableUnknown:
> + nillable = true;
> + break;
> + }
>
> - return getGeometryAttribute(tableName, columnName);
> + return getGeometryAttribute(tableName, columnName,
> nillable);
> } else {
> return super.buildAttributeType(metadataRs);
> }
> @@ -985,6 +1003,7 @@
> *
> * @param tableName The feature table name.
> * @param columnName The geometry column name.
> + * @param nillable
> *
> * @return Geometric attribute.
> *
> @@ -995,7 +1014,7 @@
> * @task This should probably take a Transaction, so if things mess
> up then
> * we can rollback.
> */
> - AttributeType getGeometryAttribute(String tableName, String
> columnName)
> + AttributeType getGeometryAttribute(String tableName, String
> columnName, boolean nillable)
> throws IOException {
> Connection dbConnection = null;
> Class type = null;
> @@ -1095,8 +1114,10 @@
> } catch (FactoryException e) {
> crs = null;
> }
> -
> - return AttributeTypeFactory.newAttributeType(columnName, type,
> true, 0, null, crs);
> +
> + int min = nillable ? 0 : 1;
> + return AttributeTypeFactory.newAttributeType(columnName, type,
> true, null, null, crs, min, 1 );
> +// return AttributeTypeFactory.newAttributeType(columnName,
> type, true, 0, null, crs);
> }
>
> private PostgisAuthorityFactory getPostgisAuthorityFactory() {
>
>
> ----------------------------------------------------------------------------------------
>
>
> Cheers
> Andrea
>
> !DSPAM:1004,45f56138128181775926497!
>
--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel