Skip Menu |
 

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

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

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

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



Subject: MySQL view_definition contains db name
Download (untitled) / with headers
text/plain 556b
Hi! Since the last update, DBIx::Class::Schema::Loader automatically creates `view_definition` for views. In case of MySQL it uses `SELECT view_definition FROM information_schema.views ...` query and the result of this query contains the database name along with every table name: `project`.`user` instead of just `user`. It's a big issue for our project since different users and environments use different database names. It would be great to have view definition without database name or at least disable view_definition generation at all. Thank you!
Subject: Re: [rt.cpan.org #119996] MySQL view_definition contains db name
Date: Thu, 26 Jan 2017 18:02:15 +0000
To: "Pushtaev Vadim via RT" <bug-DBIx-Class-Schema-Loader [...] rt.cpan.org>
From: ilmari [...] ilmari.org (Dagfinn Ilmari Mannsåker)
Download (untitled) / with headers
text/plain 1.5k
Hi Vadim, "Pushtaev Vadim via RT" <bug-DBIx-Class-Schema-Loader@rt.cpan.org> writes: Show quoted text
> Hi! > > Since the last update, DBIx::Class::Schema::Loader automatically > creates `view_definition` for views. In case of MySQL it uses `SELECT > view_definition FROM information_schema.views ...` query and the > result of this query contains the database name along with every table > name: `project`.`user` instead of just `user`.
Schema::Loader does deliberately not do anything with the view definition SQL, since that would require a fully-fledged SQL parser. This is incidentally why it does not introspect the view definition for DB2, since that only gives you the whole CREATE VIEW statement, not the body separately. Show quoted text
> It's a big issue for our project since different users and > environments use different database names. It would be great to have > view definition without database name or at least disable > view_definition generation at all.
For non-virtual views, the view definition is only used for ->deploy. The fact that you're happy with not having it generated at all makes it seem to me that you're not using deploy, so the definition is purely informative. If you really need it, you can add an sqlt_deploy_hook method to the result class that modifies $view->sql as appropriate for your specific case. Hope this helps, Ilmari -- "The surreality of the universe tends towards a maximum" -- Skud's Law "Never formulate a law or axiom that you're not prepared to live with the consequences of." -- Skud's Meta-Law
Download (untitled) / with headers
text/plain 1.8k
We do use `deploy` indeed. Previously we just added view_definition manually, but we would be happy to use auto-generated one (we have already monkey-patched Schema::Loader not to generate view_definiton as a workaround). I understand you don't want to parse SQL, but there is a way to get view definition from MySQL without database name: https://dev.mysql.com/doc/refman/5.7/en/show-create-view.html On Thu Jan 26 13:27:15 2017, ilmari@ilmari.org wrote: Show quoted text
> Hi Vadim, > > "Pushtaev Vadim via RT" <bug-DBIx-Class-Schema-Loader@rt.cpan.org> > writes: >
> > Hi! > > > > Since the last update, DBIx::Class::Schema::Loader automatically > > creates `view_definition` for views. In case of MySQL it uses `SELECT > > view_definition FROM information_schema.views ...` query and the > > result of this query contains the database name along with every table > > name: `project`.`user` instead of just `user`.
> > Schema::Loader does deliberately not do anything with the view > definition SQL, since that would require a fully-fledged SQL parser. > This is incidentally why it does not introspect the view definition for > DB2, since that only gives you the whole CREATE VIEW statement, not the > body separately. >
> > It's a big issue for our project since different users and > > environments use different database names. It would be great to have > > view definition without database name or at least disable > > view_definition generation at all.
> > For non-virtual views, the view definition is only used for ->deploy. > The fact that you're happy with not having it generated at all makes it > seem to me that you're not using deploy, so the definition is purely > informative. > > If you really need it, you can add an sqlt_deploy_hook method to the > result class that modifies $view->sql as appropriate for your specific > case. > > Hope this helps, > > Ilmari >
CC: undisclosed-recipients:;
Subject: Re: [rt.cpan.org #119996] MySQL view_definition contains db name
Date: Fri, 27 Jan 2017 12:28:26 +0000
To: "Pushtaev Vadim via RT" <bug-DBIx-Class-Schema-Loader [...] rt.cpan.org>
From: ilmari [...] ilmari.org (Dagfinn Ilmari Mannsåker)
Download (untitled) / with headers
text/plain 3.3k
"Pushtaev Vadim via RT" <bug-DBIx-Class-Schema-Loader@rt.cpan.org> writes: Show quoted text
> We do use `deploy` indeed. Previously we just added view_definition > manually, but we would be happy to use auto-generated one (we have > already monkey-patched Schema::Loader not to generate view_definiton > as a workaround).
Show quoted text
> I understand you don't want to parse SQL, but there is a way to get > view definition from MySQL without database name: > https://dev.mysql.com/doc/refman/5.7/en/show-create-view.html
That has the same problem as DB2: It includes the whole CREATE VIEW statement, not just the query. Also, whether it includes the database name (which is really the schema, in standard SQL parlance) depends on whether your current schema matches the one of the (tables used) in the view. Show quoted text
mysql> \r test mysql> show create view test.bar \G
*************************** 1. row *************************** View: bar Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`ilmari`@`%` SQL SECURITY DEFINER VIEW `bar` AS select `foo`.`id` AS `id` from `foo` character_set_client: utf8 collation_connection: utf8_general_ci 1 row in set (0.00 sec) Show quoted text
mysql> \r dbictest mysql> show create view test.bar \G
*************************** 1. row *************************** View: bar Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`ilmari`@`%` SQL SECURITY DEFINER VIEW `test`.`bar` AS select `test`.`foo`.`id` AS `id` from `test`.`foo` character_set_client: utf8 collation_connection: utf8_general_ci 1 row in set (0.00 sec) Show quoted text
> On Thu Jan 26 13:27:15 2017, ilmari@ilmari.org wrote:
>> Hi Vadim, >> >> "Pushtaev Vadim via RT" <bug-DBIx-Class-Schema-Loader@rt.cpan.org> >> writes: >>
>> > Hi! >> > >> > Since the last update, DBIx::Class::Schema::Loader automatically >> > creates `view_definition` for views. In case of MySQL it uses `SELECT >> > view_definition FROM information_schema.views ...` query and the >> > result of this query contains the database name along with every table >> > name: `project`.`user` instead of just `user`.
>> >> Schema::Loader does deliberately not do anything with the view >> definition SQL, since that would require a fully-fledged SQL parser. >> This is incidentally why it does not introspect the view definition for >> DB2, since that only gives you the whole CREATE VIEW statement, not the >> body separately. >>
>> > It's a big issue for our project since different users and >> > environments use different database names. It would be great to have >> > view definition without database name or at least disable >> > view_definition generation at all.
>> >> For non-virtual views, the view definition is only used for ->deploy. >> The fact that you're happy with not having it generated at all makes it >> seem to me that you're not using deploy, so the definition is purely >> informative. >> >> If you really need it, you can add an sqlt_deploy_hook method to the >> result class that modifies $view->sql as appropriate for your specific >> case. >> >> Hope this helps, >> >> Ilmari >>
> > > >
-- "The surreality of the universe tends towards a maximum" -- Skud's Law "Never formulate a law or axiom that you're not prepared to live with the consequences of." -- Skud's Meta-Law


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.