Is it possible to generate a text field (not VARCHAR) in the database from a string through TDatabaseManager?
I use the following attribute:
[Column('xml',[TColumnProp.Required],65535)]
In mariadb, I am getting a MEDIUMTEXT field but when validating the database, I am getting the following error:
Error: Column mytable.xml - Type mismatch. Existing: mediumtext. Target: VARCHAR($len)
You have to use a value greater than 65535 for Aurelius to consider it a memo field. So, use 65536.
That, however, will create a field of type LONGTEXT
, not MEDIUMTEXT
.
I did it:
[Column('XML',[TColumnProp.Required],65536)]
Now I am getting:
Error: Column mytable.XML - Type mismatch. Existing: mediumtext. Target: VARCHAR($len)
Error: Column mytable.XML - Type mismatch. Existing: mediumtext. Target: LONGTEXT
This table does not change and a following different class is not created as table....
I changed it manually to VARCHAR(50) to be sure that it does not stop because it finds something not expected
I am getting now:
Error: Column mydatainvoices.XML - Size/Length increased. Existing: 50. Target: 255
Error: Column mydatainvoices.XML - Type mismatch. Existing: varchar. Target: LONGTEXT
Table does not change in the db, a following class that should be created as a new table, it is not created
Sorry, the above does not work:
The class:
type
[Entity]
[Table('mydatainvcanceled')]
[Id('Fmark',TIdGenerator.None)]
[DBIndex('IDX_dat','DAT')]
[Automapping]
Tinvcanceled=class
private
Fmark: int64;
Fcancelmark: int64;
Fdat: Tdatetime;
Fxml: string;
public
property mark:int64 read Fmark write Fmark;
property cancelmark:int64 read Fcancelmark write Fcancelmark;
property dat:Tdatetime read Fdat write Fdat;
[Column('XML',[TColumnProp.Required],65536)]
property xml:string read Fxml write Fxml;
end;
Tracing fireDAC shows:
> TFDCustomCommand.Prepare [Command="CREATE TABLE mydatainvcanceled (
MARK BIGINT NOT NULL,
CANCELMARK BIGINT NOT NULL,
DAT DATETIME NOT NULL,
XML VARCHAR(255) NOT NULL,
XML LONGTEXT NOT NULL,
CONSTRAINT PK_mydatainvcanceled PRIMARY KEY (MARK))"]
Aurelius does not change the field type. It reports you with that "error", indicating that the database is not exactly as it expects, but it doesn't modify the database.
All of this is described in more details here (sections "Warnings" and "Errors"):
I know that, I read it after my previous messages. This will be a new, a non existing, table
You have mapped XML
column twice: in Xml
property, when you add the Column
attribute, and the FXml
field, when you use the Automapping
attribute. Override the automapping by adding the attribute to the field, not the property:
type
[Entity]
[Table('mydatainvcanceled')]
[Id('Fmark',TIdGenerator.None)]
[DBIndex('IDX_dat','DAT')]
[Automapping]
Tinvcanceled=class
private
Fmark: int64;
Fcancelmark: int64;
Fdat: Tdatetime;
[Column('XML',[TColumnProp.Required],65536)]
Fxml: string;
public
property mark:int64 read Fmark write Fmark;
property cancelmark:int64 read Fcancelmark write Fcancelmark;
property dat:Tdatetime read Fdat write Fdat;
property xml:string read Fxml write Fxml;
end;
Thank you this was the problem. I read in the manual that it can exist in Field or Property and I used the property for better visibility.
Please, if possible, in the next version of the aurelius, for each change have an event with an "allow_change" parameter that will allow the changing of the fields. The same for deleting tables.
Thank you again
This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.