[fdo-trac] #171: Fdo Postgis Autogenated identity property is mandatory

FDO trac_fdo at osgeo.org
Sun Apr 20 04:30:59 EDT 2008


#171: Fdo Postgis Autogenated identity property is mandatory
------------------------------+---------------------------------------------
 Reporter:  bscott            |         Owner:  mloskot
     Type:  defect            |        Status:  new    
 Priority:  major             |     Milestone:  3.4.0  
Component:  PostGIS Provider  |       Version:  3.2.0  
 Severity:  3                 |    Resolution:         
 Keywords:                    |   External_id:         
------------------------------+---------------------------------------------
Old description:

> With FDO it is possible to create a column with Primary = true and
> autogenerate = false.
> I think the PostGis provider should not do that assumption and let the
> user
> manage the primary key if the autogenerate flag is set to false.
>
> Actually it is mandatory
> there is the piece of code where you can find the limitation:
> void SchemaDescription::DescribeSchema(Connection* conn, FdoString*
> schemaName)
> {
>   ...
>         ////////////////// SET AUTO-GENERATED TO SINGLE COLUMN PK OF
>  INTEGRAL TYPE //////////////////
>
> // TODO: It is possible, that user connects to a datastore that was not
> created
> // with FDO, using ApplySchema command, so single column PRIMARY  KEY
> // of integral type, may not have associated sequence named according
> scheme:
> // <tablename>_<columnname>_seq
> // The PostGIS provider uses such scheme to bind a sequence to PK column.
>
> // TODO: In future, it would be a good idea to automatically
> // replace PK of integral type with serial data type, in ApplySchema
> command.
>      FdoPtr<FdoDataPropertyDefinitionCollection> propsIdentity;
>      propsIdentity = featClass->GetIdentityProperties();
>      if (1 == propsIdentity->GetCount())
>      {
>        FdoPtr<FdoDataPropertyDefinition> propId =
> propsIdentity->GetItem(0);
>        assert(NULL != propId);
>
>        if (FdoDataType_Int16 == propId->GetDataType()
>         || FdoDataType_Int32 == propId->GetDataType()
>         || FdoDataType_Int64 == propId->GetDataType())
>        {
>          propId->SetIsAutoGenerated(true);
>        }
>      }

New description:

 With FDO it is possible to create a column with Primary = true and
 autogenerate = false.
 I think the !PostGis provider should not do that assumption and let the
 user
 manage the primary key if the autogenerate flag is set to false.

 Actually it is mandatory
 there is the piece of code where you can find the limitation:

 {{{


 void SchemaDescription::DescribeSchema(Connection* conn, FdoString*
 schemaName)
 {
   ...
         ////////////////// SET AUTO-GENERATED TO SINGLE COLUMN PK OF
  INTEGRAL TYPE //////////////////

 // TODO: It is possible, that user connects to a datastore that was not
 created
 // with FDO, using ApplySchema command, so single column PRIMARY  KEY
 // of integral type, may not have associated sequence named according
 scheme:
 // <tablename>_<columnname>_seq
 // The PostGIS provider uses such scheme to bind a sequence to PK column.

 // TODO: In future, it would be a good idea to automatically
 // replace PK of integral type with serial data type, in ApplySchema
 command.
      FdoPtr<FdoDataPropertyDefinitionCollection> propsIdentity;
      propsIdentity = featClass->GetIdentityProperties();
      if (1 == propsIdentity->GetCount())
      {
        FdoPtr<FdoDataPropertyDefinition> propId =
 propsIdentity->GetItem(0);
        assert(NULL != propId);

        if (FdoDataType_Int16 == propId->GetDataType()
         || FdoDataType_Int32 == propId->GetDataType()
         || FdoDataType_Int64 == propId->GetDataType())
        {
          propId->SetIsAutoGenerated(true);
        }
      }


 }}}

Comment (by jbirch):

 Just fixing up the ticket description...

-- 
Ticket URL: <http://trac.osgeo.org/fdo/ticket/171#comment:3>
FDO <http://fdo.osgeo.org/>
Feature Data Objects


More information about the fdo-trac mailing list