MySQL Support
DObject O/R Mapping Suite
MySQL Support
wasuplee123
06-04-2008, 4:20 AM
Hi,
This is a great product, and I would buy it in a second if it supported MySQL on Delphi7. The main issue seems to be that it doesn't produce valid SQL code. Is there any chance that MySQL will be supported as a provider?
Thanks.
Re: MySQL Support
David
06-04-2008, 5:38 AM
Yes, you could write a sub-class TMySQLDataProvider from TDataProvider like this:
TMySQLDataProvider = class(TDataProvider)
protected
function CreateSqlBuilder: TSqlBuilder; override;
end;
function TMySQLDataProvider.CreateSqlBuilder: TSqlBuilder;
begin
Result := TMySQLSqlBuilder.Create(_UseParams, _FormatSql);
end;
And write a sub-class TMySQLSqlBuilder from TSqlBuilder:
TMySQLSqlBuilder = class(TSqlBuilder)
protected
function DQ(const value: string): string; override;
end;
function TMySQLSqlBuilder.DQ(const value: string): string;
begin
Result := '`' + value + '`';
end;
Re: MySQL Support
David
06-04-2008, 5:41 AM
You could override the virtual methods of TDataProvider and TSqlBuilder to realize your special requirement.
Any questions please feel free to contact us [
supports@macrobject.com
], thanks.
New version of MySQL Connector/ODBC
David
06-16-2008, 9:51 PM
MySQL Connector/ODBC 5.1.4, download it from:
http://dev.mysql.com/downloads/connector/odbc/5.1.html
Re: New version of MySQL Connector/ODBC
wasuplee123
07-21-2008, 9:01 PM
Thanks for all your help so far, here and in the emails.
We're using MySQLDAC (
http://www.microolap.com/products/connectivity/mysqldac/)
as our data provider in Delphi instead of ODBC. However in Code Auto, we are still using ODBC.
We noticed a problem with auto increment fields...
1) In Code Auto it doesn't show anything checked in the "AutoInc" field, even though the primary key field in our table is defined as autoincrement. (This is not really important, because I know how to modify the code generator and make all my primary key fields also be autoincrement in the "Info" file that is generated.)
2) Whenever I create a new ORM object and save it, it doesn't load the autoincrement field that was generated. For example:
---
Order = TOrder.Create(ObjectManager);
Order.Name = "Test";
Order.Save;
// Here Order.ID should not be 0, but it is
Assert(not (Order.ID = 0));
---
I tried calling Order.Refresh() but it also doesn't work. I have a function that will give me the value of the last inserted ID in MySQL, but I don't know where I should call that function in our Data Provider so that auto increment fields will get updated after saving. Thank you.
Re: New version of MySQL Connector/ODBC
Bill
07-22-2008, 1:16 AM
Thanks for your information. DObject is updated to supports auto increment fields in MySQL.
CodeAuto is updated and you can modify the "AutoInc" field in the UI manually.
Download link:
http://www.macrobject.com/en/dobject/download.htm