Skip Menu |

This queue is for tickets about the DBIx-Class-Schema-Loader CPAN distribution.

Report information
The Basics
Id: 105279
Status: resolved
Priority: 0/
Queue: DBIx-Class-Schema-Loader

People
Owner: Nobody in particular
Requestors: vanstyn [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.07043
Fixed in: (no value)



Subject: Wildcard '%' value for db_schema does not work in MySQL
Setting the loader option 'db_schema' to the documented wildcard value of '%' - which is supposed to mean "All Schemas" - does not work in MySQL. It causes all schemas (same as databases for MySQL) to show up as table names and fail. This broken behavior can also be seen by calling: $self->dbh->tables(undef, '%') Which returns a list of quoted schema names... Ref: https://metacpan.org/pod/DBIx::Class::Schema::Loader::Base#db_schema Convo from IRC: ===================== <--snip--> <vanstyn> Should I expect Schema::Loader's db_schema option to work when set to '%' in MySQL ? <vanstyn> ilmari: ^^ <vanstyn> when I use it, it looks like it is seeing the database names as table names, and elsewhere is trying to use the literal string '%' .... I get errors like this: https://gist.github.com/vanstyn/312faa9f03a3ef4eaf92 <vanstyn> I know I'm entering the param correctly, because when I supply a real name it works as expected <ilmari> vanstyn: it should, that's clearly a bug <ilmari> vanstyn: care to file it in RT <ilmari> ? <ilmari> vanstyn: does it work if you specify an arrayref of schema names? <vanstyn> ilmari: I'll try that (and I'll also file an RT) <vanstyn> ilmari: yes, it works as expected with an arrayref of valid schema names.... <ilmari> and what does $dbh->tables(undef, '%') return? <ilmari> nevermind, I can do that myeslf <ilmari> that returns a list of quoted schema names <ilmari> which is what ->table_info(undef, '%', undef) is documented to return <ilmari> how did that ever work? <ilmari> ah, that's one of the "special cases [which] may also be supported by some drivers" <ilmari> ffs <ilmari> I'll have a look at it later <--snip-->
And on a potentially related topic, (testing on Pg), when *not* setting a value for db_schema, these warnings get thrown: Use of uninitialized value $schema in string ne at .../site_perl/5.18.2/DBIx/Class/Schema/Loader/DBI.pm line 155. Which also appears to be blatantly a bug, since $schema is initialized by the for() loop (starting at line 130) which sets the list to a single undef value by design...
CC: undisclosed-recipients:;
Subject: Re: [rt.cpan.org #105279] Wildcard '%' value for db_schema does not work in MySQL
Date: Sun, 21 Jun 2015 23:49:53 +0200
To: bug-DBIx-Class-Schema-Loader [...] rt.cpan.org
From: ilmari [...] ilmari.org (Dagfinn Ilmari Mannsåker)
"Henry Van Styn via RT" <bug-DBIx-Class-Schema-Loader@rt.cpan.org> writes: Show quoted text
> Setting the loader option 'db_schema' to the documented wildcard value > of '%' - which is supposed to mean "All Schemas" - does not work in > MySQL. It causes all schemas (same as databases for MySQL) to show up > as table names and fail.
The '%' should not be making it through to the actual ->db_schema value, since DBIx::Class::Schema::Loader::DBI::mysql->_setup expands it to the actual list of databases. Show quoted text
> This broken behavior can also be seen by calling: > > $self->dbh->tables(undef, '%') > > Which returns a list of quoted schema names...
This, however, is a bug in DBD::mysql. This special behaviour should only be triggered if the catalog and table names are empty strings, while undef should be interpreted as '%'. Show quoted text
> And on a potentially related topic, (testing on Pg), when *not* setting > a value for db_schema, these warnings get thrown:
Show quoted text
> Use of uninitialized value $schema in string ne > at .../site_perl/5.18.2/DBIx/Class/Schema/Loader/DBI.pm line 155.
Show quoted text
> Which also appears to be blatantly a bug, since $schema is initialized > by the for() loop (starting at line 130) which sets the list to a single > undef value by design...
This should also not be possible, since DBIx::Class::Schema::Loader::DBI::Pg->_setup defaults db_schema to ['public']. Are you by any chance subclassing the loader class, overriding _setup and failing to call ->next::method? -- "A disappointingly low fraction of the human race is, at any given time, on fire." - Stig Sandbeck Mathisen
On Sun Jun 21 17:50:15 2015, ilmari@ilmari.org wrote: Show quoted text
> <--snip--> > > Are you by any chance subclassing the loader class, overriding _setup > and failing to call ->next::method? >
I am subclassing the loader class, but not overriding _setup and not forgetting to call next::method in any instances... however, now that you mention it, it could be related to something going wrong with the funky stuff I am doing to try to dynamically load the given driver in new(): RapidApp::Util::MetaKeys::Loader <-- on cpan If this is only an issue in my setup, I'm fine. (however, if you have suggestions for how I should handle this subclass differently, I'm all ears)
CC: undisclosed-recipients:;
Subject: Re: [rt.cpan.org #105279] Wildcard '%' value for db_schema does not work in MySQL
Date: Fri, 26 Jun 2015 18:50:27 +0200
To: bug-DBIx-Class-Schema-Loader [...] rt.cpan.org
From: ilmari [...] ilmari.org (Dagfinn Ilmari Mannsåker)
"Henry Van Styn via RT" <bug-DBIx-Class-Schema-Loader@rt.cpan.org> writes: Show quoted text
> Queue: DBIx-Class-Schema-Loader > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=105279 > > > On Sun Jun 21 17:50:15 2015, ilmari@ilmari.org wrote:
>> <--snip--> >> >> Are you by any chance subclassing the loader class, overriding _setup >> and failing to call ->next::method? >>
> > I am subclassing the loader class, but not overriding _setup and not > forgetting to call next::method in any instances... however, now that > you mention it, it could be related to something going wrong with the > funky stuff I am doing to try to dynamically load the given driver in > new(): > > RapidApp::Util::MetaKeys::Loader <-- on cpan > > If this is only an issue in my setup, I'm fine. (however, if you have > suggestions for how I should handle this subclass differently, I'm all > ears)
Your problem is that DBIx::Class::Schema::Loader::DBI->new doesn't rebless when you're using a custom loader class, so its call to ->_setup just calls the empty one in DBI. You need to call it again after reblessing. -- "A disappointingly low fraction of the human race is, at any given time, on fire." - Stig Sandbeck Mathisen
Finally coming back to this -- confirmed that ilmari was correct, and the PR he was nice enough to send me (https://github.com/vanstyn/RapidApp/pull/159) in fact fixes the problem... ilmari++ Thanks! vanstyn On Fri Jun 26 12:50:57 2015, ilmari@ilmari.org wrote: Show quoted text
> "Henry Van Styn via RT" <bug-DBIx-Class-Schema-Loader@rt.cpan.org> > writes: >
> > Queue: DBIx-Class-Schema-Loader > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=105279 > > > > > On Sun Jun 21 17:50:15 2015, ilmari@ilmari.org wrote:
> >> <--snip--> > >> > >> Are you by any chance subclassing the loader class, overriding _setup > >> and failing to call ->next::method? > >>
> > > > I am subclassing the loader class, but not overriding _setup and not > > forgetting to call next::method in any instances... however, now that > > you mention it, it could be related to something going wrong with the > > funky stuff I am doing to try to dynamically load the given driver in > > new(): > > > > RapidApp::Util::MetaKeys::Loader <-- on cpan > > > > If this is only an issue in my setup, I'm fine. (however, if you have > > suggestions for how I should handle this subclass differently, I'm all > > ears)
> > Your problem is that DBIx::Class::Schema::Loader::DBI->new doesn't > rebless when you're using a custom loader class, so its call to ->_setup > just calls the empty one in DBI. You need to call it again after > reblessing. >