Thanks for your help. On Mon, Sep 12, 2011 at 6:06 PM, neil.lunn <[email protected]> wrote:
> > 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/Cookbook.pod#Creating_DDL_SQL > I guess what I didn't make clear is that the DDL is for creating temporary tables and views and shuttling data around within a transaction (this is with PostgreSQL). So I don't need to spit it out to a file, just run it on the dbh that belongs to this schema. The DDL isn't really that complex, I guess. Generating it is tricky, and based upon schema reflection, but I already have code that can do it by calling methods on the Result class. > 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. > Yes, I do need to install this DDL live. The problem is that if I define extra methods on my Result class: package My::Schema::Result::MyTable; ... table definition auto-generated by DBIx::Class::Loader ... sub foo { ... } 1; use My::Schema; My::Schema->resultsource('MyTable')->foo(...); I get an error that foo is not defined on DBIx::Class::ResultSource. It's not clear from the DBIx::Class documentation when My::Schema::Result::MyTable would get instantiated... I think perhaps as a Row? 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. > Yep, I can do that, by directly importing My::Schema::Result::MyTable. But the problem is that it's not connected to a dbh, so it can't execute DDL. - Lyle
_______________________________________________ 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/[email protected]
