[Dbix-class] RFC: Name and comments on my new module.
John Napiorkowski
jjn1056 at yahoo.com
Tue May 20 15:12:24 BST 2008
--- On Tue, 5/20/08, luke saunders <luke.saunders at gmail.com> wrote:
> From: luke saunders <luke.saunders at gmail.com>
> Subject: Re: [Dbix-class] RFC: Name and comments on my new module.
> To: jjn1056 at yahoo.com, "DBIx::Class user and developer list" <dbix-class at lists.scsys.co.uk>
> Date: Tuesday, May 20, 2008, 9:47 AM
> On Tue, May 20, 2008 at 2:32 AM, John Napiorkowski
> <jjn1056 at yahoo.com> wrote:
> > Hi,
> >
> > I need help for my module name, hoping for
> someone's creative insight. Also would enjoy any
> comments. This is a DBIC::Schema component and stand alone
> class this is like a $schema->populate on steroids. What
> it does is make it easier when you are doing a first time
> setup and need to insert a bunch of rows, like the first
> time you deploy a new database, or after you update it.
> It's not as full featured as DBIC::Fixtures, and is
> targeted more directly at making it easier to just take a
> perl structure, or one loaded from a configuration file,
> and setup your database.
> >
> > Basically all it does is take:
> >
> > my $setup_rows = [
> >
> > {Gender => {
> > fields => 'label',
> > data => {
> > male => 'male',
> > female => 'female',
> > }}},
> >
> > {Person => {
> > fields => ['name', 'age',
> 'gender', 'emails'],
> > data => {
> > john => ['john', 38,
> "!Index:Gender.male", {
> > fields => ['email',
> 'private'],
> > data => {
> > personal => ['hey at home.net', 1],
> > work => ['j at biz.com', 0],
> > },
> > }],
> > jane => ['jane', 40,
> '!Index:Gender.female'],
> > }}},
> >
> > {FriendList => {
> > fields => ['person', 'friend'],
> > data => {
> > john_jane => ['!Index:Person.john',
> '!Index:Person.jane'],
> > }}},
> > ];
> >
> > and let's you put rows into your schema with:
> >
> > $schema->populate_via_hashref($setup_rows);
> >
> > The main thing over the standard populate -or even
> insert- is that each $setup_rows is traversed via a visitor
> class so it can process the values and expand a macro-like
> "!Macro:args". This makes it easier to do things
> like setup a database with relationships and not have to
> predetermine the keys, or include defaults dates (with
> something like "!Date:now' or
> "!Date::yesterday") or even base inserted values
> on %ENV. Your thoughts on additional builtin macros
> wanted.
> >
> > I'm actually using DBIC::Fixtures myself now, but
> I wrote this for some previous jobs and thought it might
> come in handy for someone else. It's probably not what
> you want to use if you are installing 100's of rows,
> need to dump and reload your db, since DBIC::Fixtures is
> great for that. It's got a decent test suite and all,
> just need a good name for it to live on CPAN. I just need
> a name (been using DBIx::Class::PopulateViaHashRef
> internally) and your comments.
> >
>
> Sounds interesting. Any chance of seeing the code and
> tests?
>
> Cheers,
> Luke.
I'll put it out there tonight. I was going to just grab a space on google code, but 1) wanted to make sure people were cool with the Namespace, since I wanted it under DBIx::Class::..... and don't want to take something Mst or co have a plan for and 2) was wondering if it was better stuck somewhere in the DBIC repo.
--John
More information about the DBIx-Class
mailing list