Recognize columns with default values, treat them accordingly
-------------------------------------------------------------

                 Key: GEOT-2526
                 URL: http://jira.codehaus.org/browse/GEOT-2526
             Project: GeoTools
          Issue Type: Improvement
          Components: data jdbc-ng
    Affects Versions: 2.5.5
            Reporter: Andrea Aime
            Assignee: Andrea Aime
             Fix For: 2.6-M2


At the moment columns with a default value receive no special treatment. There 
are two things we could do:
a) don't mark the column as non nullable if the schema says "not null" if the 
column has a default value
b) don't force a null value during feature insertion if the attribute value has 
not been specified, as the default value will be provided by the database

In order to recognize a column with a default value we can use the COLUMN_DEF 
metadata, see DatabaseMetadata.getColumns() javadoc:
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html

Behaviour a) seems easy enough to get, we just check COLUMN_DEF is not null, in 
that case, we ignore the information provided by NULLABLE.

b) is tricky in a few ways. Afaik we have no way to tell if an attribute is not 
set, or set with a null value. That is, how do we tell apart a user asking for 
an explicit null from one that simply did not set the attribute?
If we have no way, would it be ok to just assume that null attribute + default 
value -> use the default value?

The other issue is, if we avoid setting null for null attributes with a default 
value, should we issue an extra query in the db to retrieve the generated 
default value, or not? And, can we even do this? I guess in the case of a 
writer the feature is owned by the writer itself and it's updatable, in the 
case of FeatureStore.addFeatures we _could_ update the features passed in



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to