Hello!
I have a problem saving boolean property to the MySQL DB. It always wants to save "Y" instead of "1" for boolean = true.
The manager configured like this:
constructor TBaseManager.Create(Owner: TComponent; Connection: TZConnection);
var Generator: TMySQLSQLGenerator;
begin
inherited Create(Owner);
FConnection := Connection;
// Doesn't work. Disabled, because tried directly on FManager
// Generator := (TSQLGeneratorRegister.GetInstance.GetGenerator('MySQL') as TMySQLSQLGenerator);
// Generator.UseBoolean := true;
FDbConnection := TZeosLibConnectionAdapter.Create(FConnection, false);
FDbManager := TDatabaseManager.Create(FDbConnection);
FManager := TObjectManager.Create(FDbConnection);
(FManager.SQLGenerator as TMySQLSQLGenerator).UseBoolean := true;
TMappingExplorer.Default.Events.OnSqlExecuting.Subscribe(
procedure(Args: TSQLExecutingArgs)
begin
Log(llVerbose, 'Aurelius: '+Args.SQL);
end
);
end;
DB is configured like this
CREATE TABLE `users` (
`LOGIN` VARCHAR(20) NOT NULL,
`PASS` VARCHAR(20) NOT NULL,
`REAL_NAME` VARCHAR(255) NULL DEFAULT NULL ,
`ACTIVE` TINYINT(4) UNSIGNED NOT NULL DEFAULT '0',
`LAST_LOGIN` DATETIME NULL DEFAULT NULL,
`POS_PASS` VARCHAR(50) NULL DEFAULT '123' ,
`TAX_ID` VARCHAR(50) NULL DEFAULT NULL ,
`READ_ONLY` CHAR(1) NULL DEFAULT '0' ,
PRIMARY KEY (`LOGIN`) USING BTREE
)
COLLATE='cp1250_croatian_ci'
ENGINE=MyISAM
;
Object
[Entity]
[Table('users')]
[Id('FUserName', TIdGenerator.None)]
TUser = class
private
[Column('LOGIN', [TColumnProp.Unique])]
FUserName: string;
[Column('REAL_NAME')]
FRealName: string;
[Column('ACTIVE')]
FActive: boolean;
[Column('PASS')]
FPassword: string;
[Column('POS_PASS')]
FPasswordPOS: string;
[Column('LAST_LOGIN')]
FLastLogin: TDateTime;
[Column('TAX_ID')]
FTaxId: string;
[Column('READ_ONLY')]
FIsReadOnly: boolean;
FRoles: Proxy<TList<TUserRole>>;
public
constructor Create; reintroduce;
destructor Destroy; override;
property Active: boolean read FActive write FActive;
property Password: string read FPassword write FPassword;
property PasswordPOS: string read FPasswordPOS write FPasswordPOS;
property Username: string read FUsername write FUsername;
property RealName: string read FRealName write FRealName;
property LastLogin: TDateTime read FLastLogin write FLastLogin;
property Level: integer read FLevel write FLevel;
property TaxId: string read FTaxId write FTaxId;
property IsReadOnly: boolean read FIsReadOnly write FIsReadOnly;
[ManyValuedAssociation([TAssociationProp.Lazy], CascadeTypeAllRemoveOrphan, 'FUser')]
property Roles: Proxy<TList<TUserRole>> read FRoles write FRoles;
end;
I tried BIT and TINYINT, but no way. I know that I'm doing something wrong, I just can't find what