Hi,
We've been using Rose::DB for our project for the past six years or so.
We have a primary development system where our code lives, plus each developer uses his own machine for work in progress.
These are all running Ubuntu 16.04.
Recently I noticed on my own machine the Rose::DB::Object::Loader->make_modules() method was failing with this error:
Could not auto-generate columns for class SuntrixBackend::DB::AlertContact - no column info found for catalog '' schema 'public' table 'alert_contacts' at /usr/share/perl5/Rose/DB/Object/Loader.pm line 1078.
After some experimentation and judicious editing of Rose::DB::Object::Metadata::Auto.pm I traced the problem to this code in Auto.pm->auto_generate_columns:
CHECK_TABLE: # Make sure this column is from the right table
{
no warnings; # Allow undef coercion to empty string
$col_info->{'TABLE_NAME'} = $db->unquote_table_name($col_info->{'TABLE_NAME'});
next COLUMN unless($col_info->{'TABLE_CAT'} eq $catalog &&
$col_info->{'TABLE_SCHEM'} eq $schema &&
$col_info->{'TABLE_NAME'} eq $table_unquoted);
}
and the issue is that $col_info->{'TABLE_CAT'} is NOT equal to $catalog. TABLE_CAT is 'suntrix' and $catalog is empty.
Eventually I traced this to DBD-Pg.pm, which on my "broken" system is version 3.10.5 but on the other systems is 3.5.3.
(It was working fine on my system a few weeks ago. I can only assume the DBD-Pg update found its way onto the Ubuntu package server a few weeks ago.)
The old (working) version always sets TABLE_CAT to NULL, the new version sets it to the database name.
The DBD-Pg changelog says,
Version 3.8.0 (released April 25, 2019)
...
- Return the current database name as TABLE_CAT in info methods
[Dagfinn Ilmari Mannsåker]
...
So, what's the correct way to handle this? Is the change to DBD-Pg "wrong" i.e. setting the catalog name to the database name is poor behaviour?
Or should Rose::DB be updated to handle this situation?
Thanks,
Jeremy Begg