Unique field with Interbase 2020


I am reading the book Modern Software Devlopment With Delphi, and I am trying to use Aurelius with Interbase 2020.

There is this simple Entity:

  TCustomer = class

    [Column('Address', [], 2000)]
    FAddress: string;
    FEmail: String;
    FId: Integer;

    [Column('Name', [TColumnProp.Unique])]
    FName: String;

    FContact: String;
    function GetAddressExcel: String;

    constructor Create;

    property Id: Integer read FId write FId;

    property Name: string read FName write FName;
    property Contact: String read FContact write FContact;
    property Address: string read FAddress write FAddress;
    property Email: String read FEmail write FEmail;

    property AddressExcel: String read GetAddressExcel;

The error I get:

-- ERROR: ERROR: unsuccessful metadata update
Column: NAME not defined as NOT NULL - cannot be used in PRIMARY KEY/UNIQUE constraint definition

Should the TColumnProp.Unique attribute add the not null by default in case we use Interbase?


You should use [TColumnProp.Unique, TColumnProp.Required] .

:thinking: It's a good philosophical question, especially considering that apparently this Interbase requirement (not defined as NOT NULL - cannot be used in PRIMARY KEY/UNIQUE constraint definition) is not the standard.

1 Like

What do you think Wagner? Should the prop.unique also apply required by default? So that if I change back end it would still be compatible?


i don't think so.
Personally this looks like a weird Interbase limitation, it's very specific so it should be worked around manually. All other databases I know accept unique keys with nulls.

Thanks for the precision Wagner.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.