Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Possible bug in SQL datasource where PK field name != table field name

    I have a datasource where the name of the primary key field in the datasource differs from the actual name of the field in the database:

    Code:
    <field name="beneficiary_approval_id" detail="true" nativeName="id" type="sequence" primaryKey="true" />
    In buld 2014-04-26 of smartgwt power edition there seems to be a bug when I add new records using this datasource.

    The actual insert is correct, but the auto-fetch performed by smartgwt seems to try to use the incorrect field name in the constraint.

    See the log extract on an add:

    Code:
    === 2014-05-08 12:45:04,115 [l0-2] INFO  SQLDriver - [builtinApplication.beneficiary_add] Executing SQL update on 'MSSQL': INSERT INTO lor_beneficiary_approvals (bingo_warning, max_no_of_bingos, organization_id, special_term, valid_from) VALUES ('false', 1, 10712, 'false', '20140508')
    === 2014-05-08 12:45:04,136 [l0-2] INFO  SQLDataSource - [builtinApplication.beneficiary_add] primaryKeys: {id=2014000194}
    === 2014-05-08 12:45:04,136 [l0-2] INFO  SQLDataSource - [builtinApplication.beneficiary_add] MSSQL getLastRow(): using default operationBinding
    === 2014-05-08 12:45:04,137 [l0-2] INFO  SQLDataSource - [builtinApplication.beneficiary_add, builtinApplication.null] Performing fetch operation with
    	criteria: {id:2014000194}	values: {id:2014000194}
    === 2014-05-08 12:45:04,137 [l0-2] INFO  SQLDataSource - [builtinApplication.beneficiary_add, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM 
         lor_beneficiary_approvals 
         	 left outer join organizations on lor_beneficiary_approvals.organization_id = organizations.id
             left outer join lor_annulment_causes on lor_annulment_causes.id = lor_beneficiary_approvals.annulment_cause_id 
             left outer join view_grunndata_er on view_grunndata_er.orgnr = organizations.orgno
             left outer join view_grunndata_friv on view_grunndata_friv.orgno = organizations.orgno
             left outer join archive_reference on archive_reference.id = lor_beneficiary_approvals.approval_archive_reference_id
             left outer join archive_reference deleted_reference on deleted_reference.id = lor_beneficiary_approvals.deleted_archive_reference_id     
         
          WHERE $defaultWhereClause
    === 2014-05-08 12:45:04,138 [l0-2] INFO  SQLDataSource - [builtinApplication.beneficiary_add, builtinApplication.null] 33: Executing SQL query on 'MSSQL': SELECT lor_beneficiary_approvals.annulment_cause_id, lor_annulment_causes.name AS annulment_cause_name, archive_reference.reference AS approval_reference, lor_beneficiary_approvals.approval_archive_reference_id AS approval_reference_id, archive_reference.url AS approval_url, lor_beneficiary_approvals.id AS beneficiary_approval_id, lor_beneficiary_approvals.bingo_comment, lor_beneficiary_approvals.bingo_warning, lor_beneficiary_approvals.bingo_warning_text, lor_beneficiary_approvals.deleted_archive_reference_id, lor_beneficiary_approvals.deleted_from, deleted_reference.reference AS deleted_reference, deleted_reference.url AS deleted_url, view_grunndata_friv.category1 AS icnpo_1, view_grunndata_friv.description1 AS icnpo_1_description, view_grunndata_friv.category2 AS icnpo_2, view_grunndata_friv.description2 AS icnpo_2_description, view_grunndata_friv.category3 AS icnpo_3, view_grunndata_friv.description3 AS icnpo_3_description, lor_beneficiary_approvals.max_no_of_bingos, lor_beneficiary_approvals.membership_data_timestamp, view_grunndata_er.navn, lor_beneficiary_approvals.no_of_members, lor_beneficiary_approvals.no_of_members_below_18, lor_beneficiary_approvals.organization_id, organizations.orgno, view_grunndata_er.postnrSted, lor_beneficiary_approvals.special_term, lor_beneficiary_approvals.valid_from FROM 
         lor_beneficiary_approvals 
         	 left outer join organizations on lor_beneficiary_approvals.organization_id = organizations.id
             left outer join lor_annulment_causes on lor_annulment_causes.id = lor_beneficiary_approvals.annulment_cause_id 
             left outer join view_grunndata_er on view_grunndata_er.orgnr = organizations.orgno
             left outer join view_grunndata_friv on view_grunndata_friv.orgno = organizations.orgno
             left outer join archive_reference on archive_reference.id = lor_beneficiary_approvals.approval_archive_reference_id
             left outer join archive_reference deleted_reference on deleted_reference.id = lor_beneficiary_approvals.deleted_archive_reference_id     
         
          WHERE ('1'='1')
    Notice that the actual select has a WHERE 1=1 constraint and that the system logs the constraints it uses in the fetch

    <i>Performing fetch operation with
    criteria: {id:2014000194} values: {id:2014000194}</i>

    I would expect the field name to be beneficiary_approval_id and not id in the criteria?

    BTW. If I change the name of the beneficiary_approval_id field to "id", the subsequent select is correct.

    Regards
    Rolf

    #2
    Can you get the same effect by just modifying a sample DataSource to change the PK field name to something else and using nativeName, and attempting an insert? If so, please show the necessary modifications and we'll take a look.

    Comment


      #3
      Okay.

      I will create a test case for this as soon as I get the time.

      Rolf

      Comment

      Working...
      X