JDBCTextFeatureWriter.makeInsertSql() doesn't work for NOT NULL fields
----------------------------------------------------------------------

         Key: GEOT-727
         URL: http://jira.codehaus.org/browse/GEOT-727
     Project: GeoTools
        Type: Bug
  Components: main  
    Versions: 2.2.M0    
 Reporter: Paolo Rizzi
 Assigned to: James Macgill 
     Fix For: 2.2.M1


The JDBCTextFeatureWriter.makeInsertSql() always create an SQL with all
the AttributeTypes of a Feature. For example if a Feature must go into a table 
like this:
   CREATE TABLE TBL (
      KKK VARCHAR(10) NOT NULL DEFAULT 'xxx',
      VVV NUMBER
   )
an SQL like this will be generated for a Feature with a null KKK and VVV=100:
      INSERT INTO TBL (KKK,VVV) VALUES (null,100)
This is wrong because, for example PostgreSQL, won't use the provided 'xxx' 
default
and will complain because the field id NOT NULL.
So the generated SQL should be:
      INSERT INTO TBL (VVV) VALUES (100)
this way the RDBMS will use the provided 'xxx' default.

For a Feature with KKK='' and VVV=100 we'll have:
      INSERT INTO TBL (KKK,VVV) VALUES ('',100)
This may cause the same problem with some RDBMS.
For example Oracle treats empty strings like nulls, 
so a '' will be seen as a null and not accepted in a NOT NULL field.

In this case, either a specific makeInsertSql() methid is neede for Oracle, or 
a simple 
   protected boolean treatsEmptyStringsAsNulls
flag may be added to support such RDBMSes.



-- 
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



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to