ORM Delete with primary key does not work

Home Forums kbmMW ORM Delete with primary key does not work

Viewing 1 reply thread
  • Author
    Posts
    • #54125
      mrluigi2017
      Participant

      Hi,

      In my application I have a class with the following field in it:

      [kbmMW_Field(‘name:party_id, primary:true, generator:sequence’, ftInteger)]
      [kbmMW_Element(‘party_id’)]
      property PartyId: kbmMWNullable<integer> read FPartyId write FPartyId;

      When I try to delete a record with this code however I get an exception.

      RowAffected := DmServer.Orm.Delete<TParty>([APartyID]);

      The exception is:
      ‘Field party_id not found in class’, 0, nil, nil, False

      The “sql” generated in kbmmw looks like this:
      DELETE FROM EntityParty.TParty WHERE (party_id=:P1)

      When I explicitly use the class’s fieldname it works fine.
      Orm.Delete<TParty>([‘PartyId’],[APartyID]); // Works fine

      It looks like kbmmw mixes Native with MW in one statement.

      If I just query it works fine with the same syntax.
      Orm.Query<TParty>([APartyID]); // Works fine

      My Orm query mode is set to mixed.

      Any ideas what might be the cause of this problem?

      Thanks in advance!

      Luigi

      • This topic was modified 5 months, 2 weeks ago by mrluigi2017.
    • #54127
      kimbomadsen
      Keymaster

      Hi,

      Thank you for your report. You are right. There is a bug. It will be fixed in next release. To fix:

      Add new method to TkbmMWORMFieldList class in kbmMWORM.pas:

      function AsFieldRTTINameArray:TArray<string>;

      function TkbmMWORMFieldList.AsFieldRTTINameArray:TArray<string>;
      var
      i,n:integer;
      begin
      n:=Count;
      SetLength(Result,n);
      for i:=0 to n-1 do
      Result[i]:=Items[i].RTTIName;
      end;

      Search and change AsFieldNameArray to AsFieldRTTINameArray where it is called in kbmMWORM.pas (function TkbmMWORM.InternalDelete<T> and function TkbmMWORM.InternalUpdate<T>)

      Then it should work fine.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.
Skip to toolbar