FindOne<T> where id as TGuid

Issue #385 resolved
Marcelo Borgues created an issue

Methods like FindOne, for example, expect parameters of type TValue and when trying to use im TGuid, the error occurs: incompatible types: TValue and TGUID.

Comments (6)

  1. Stefan Glienke repo owner

    Because TValue does not have an implicit operator for TGUID. You need to explicitly wrap the TGuid into a TValue with TValue.From(aId)

  2. Marcelo Borgues reporter

    after doing that i have this message in select or inserts/updates. My database is oracle and the models are mapped as TGuid, but with other data types like TArray<System.byte>, the same thing happens.

  3. Stefan Glienke repo owner

    You need to consult the FireDAC help about that exception and possibly add some data type mapping options.

  4. Marcelo Borgues reporter

    I believe that I have no problems with Firedac, since using the FDQuery component insertions of GUID types occur normally, only via Marshmallow do I observe problems with this data type, any parameterization in Firedac would break the use of native FDQuery.

  5. Stefan Glienke repo owner

    Then you need to step through the code and check what data type it is complaining about and why it cannot properly insert a TGuid - possibly it does not set the required datatype for the parameter.
    This should happen in TDBParam.TypeInfoToFieldType in Spring.Persistence.SQL.Params.pas

    With the limited information you provide, I cannot give you any solution.

  6. Stefan Glienke repo owner

    I just tested using the TFireDACConnectionAdapter with a TFDConnection fetching some entity with a primary key property that is TGUID on SQL Server and it works - so it looks to be an oracle specific issue. Is the database column RAW(16)? Then it looks to be a mapping/conversion issue between ftGuid and that field. If it works with a TFDQuery please check what fieldType is created for that column.

  7. Log in to comment