Page 1 of 1

problem with ttable component in lazarus

Posted: 20.01.2013, 11:08
by aducom
It's been a while I used Zeos. Nice to be back here. I looked at the latest version in Lazarus 1.0.4. Install went well. But if I want to select a table then using the pulldown of tablenames generates an error. GetTableNames also generates an error. Now it's obvious to think that it's because of MySQL, but I'm running mySQL 5.1 and using 'show tables like '%' simply works in my MySQL maintenance tool. With lazarus I get

SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near LIKE '%' at line 1.

Now diving into the code it appears that there's no database name. I forgot to add it, stupid enough. It might be a suggestion to generate a more appropiate errormessage? After all you can connect to the database without having selecting a database name.

Code: Select all

function TZMySQLDatabaseMetadata.UncachedGetTables(const Catalog: string;
  const SchemaPattern: string; const TableNamePattern: string;
  const Types: TStringDynArray): IZResultSet;
var
  LCatalog, LTableNamePattern: string;
begin
    Result := inherited UncachedGetTables(Catalog, SchemaPattern, TableNamePattern, Types);

    GetCatalogAndNamePattern(Catalog, SchemaPattern, TableNamePattern,
      LCatalog, LTableNamePattern);

    if LCatalog='' then
       raise Exception.Create('Error: missing catalog name');

    with GetConnection.CreateStatement.ExecuteQuery(
      Format('SHOW TABLES FROM %s LIKE ''%s''',
      [GetIdentifierConvertor.Quote(LCatalog), LTableNamePattern])) do
    begin
  

Posted: 20.01.2013, 15:03
by EgonHugeist
aducom,


i'm glad to see a DevMember back! Each help is welcome.
I forgot to add it, stupid enough. It might be a suggestion to generate a more appropiate errormessage?
Well that looks like a good idea. Would you like to attach a patch? Did you work with our SVN in the past? Or do you wanna waiting for a done job? (;

Posted: 20.01.2013, 16:03
by aducom
I was introduced a long time ago in the days of Zeos 4. I have worked with svn before, but mostly I send my remarks to Mark. But I don't mind making the changes into the branch myself. I don't need to wait for a done job ;-)
I need new credentials though.

Posted: 20.01.2013, 18:06
by EgonHugeist
aducom,
I was introduced a long time ago in the days of Zeos 4. I

but mostly I send my remarks to Mark.
Keep going on this way OR give me your SF.Net username to grand you access. But i propose you mail Mark first.

Posted: 30.01.2013, 21:29
by mdaems
Maybe better to just drop the from part from the metadata query when the database name is empty?
Don't know if that is very usefull when no database is 'active' on the connection. But at least, it's not a faulty query.

Mark