[Dbix-class] Get table name from ResultSet class?

neil.lunn neil at mylunn.id.au
Tue Sep 13 01:06:53 GMT 2011


Was there some reason that this was not good enough for your purposes:
http://search.cpan.org/~abraxxa/DBIx-Class-0.08195/lib/DBIx/Class/Manual/Co=
okbook.pod#Creating_DDL_SQL =

<http://search.cpan.org/%7Eabraxxa/DBIx-Class-0.08195/lib/DBIx/Class/Manual=
/Cookbook.pod#Creating_DDL_SQL>

If you really need something more complex than that then you need to be =

looking at the ResultSource objects rather than the ResultSet. Or use =

them direct as I really don't think you need an active connection to do =

this, unless you are trying to do some sort of schema deploy on connect.

basically

use My::Schema::Result::MyTable;
print My::Schema::Result::MyTable->table();

or any other accessor that is valid for the ResultSource is always going =

to work in any way you basically do that.

On 13/09/2011 10:28 AM, Lyle Kopnicky wrote:
> Hi folks,
>
> I'm pretty new to DBIx::Class. I'm working on a project where I'm =

> mainly using DBIx::Class as a way to get metadata for the tables, then =

> use that to generate DDL. The DDL I'm generating is kind of complex =

> and isn't handled very well by SQL::Abstract.
>
> I tried hanging code off of the Result classes to generate the DDL, =

> and that works fine, except it means I have to import the Result =

> classes directly, and then they were not connected to a database, so =

> they couldn't provide a dbh.
>
> So instead I tried getting a ResultSource or ResultSet from the schema =

> that was already connected to a database. But then I don't have access =

> to the methods I added to the Result object.
>
> So I tried creating a parallel set of ResultSet objects and adding my =

> custom methods there. Then I was able to access the methods from the =

> ResultSet, but they could no longer access the table method to get the =

> table name.
>
> How can I get the table name from the ResultSet? Is it purposely hidden?
>
> -- =

> Lyle Kopnicky | Software Developer
> 503.284.7581 x260 | lwk at rentrak.com <mailto:axc at rentrak.com>
> RENTRAK | www.rentrak.com <http://www.rentrak.com/> | NASDAQ: RENT
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.=
co.uk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20110913/eca=
aae8b/attachment.htm


More information about the DBIx-Class mailing list