Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Given a schema like so:use Moose; with 'orm'; has table => ( name => 'my_database_table' );
+--------------------+------------------+ | Field | Type | +--------------------+------------------+ | id | int(10) unsigned | | field1 | varchar(32) | | field2 | varchar(32) | +--------------------+------------------+My ORM.pm role would parse this line:
And effectively produce a Moose object that would be essentially the same as explicitly coding:has table => ( name => 'my_database_table' );
The idea, however, is not to produce a text file ... but rather an in-memory object. I could always use Perl to create the text file for me, i.e. this one liner:use Moose; has id => ( is => 'ro', isa => 'Int' ); has field1 => ( is => 'rw', isa => 'Str' ); has field2 => ( is => 'rw', isa => 'Str' );
I have searched for others who might have this same desire, but so far no real luck. I imagine will need to use Moose::Exporter or possibly Moose::Util::MetaRole. I really don't know.mysql -e 'desc my_database_table' | cut -f1 | perl -ple '$_=qq{has $_ +=> ( is => "rw" );}'
So, my question isn't "can someone do this for me?" but rather ... are there any Moose heads out there who might be able to sketch out a rough game plan for solving this problem. Personally, I am starting to believe this is more trouble than it is worth. But please remember -- I am not looking for a fully functional ORM that handles complex relationships -- just some sugar for preventing having to spell out the names of the columns in the table for now. I myself am not sure this is a great idea. :)
Thanks in advance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Moose + ORM
by Corion (Patriarch) on Jul 23, 2009 at 18:35 UTC | |
by Anonymous Monk on Jul 23, 2009 at 18:52 UTC | |
by Anonymous Monk on Jul 25, 2009 at 21:57 UTC | |
by Anonymous Monk on Jul 23, 2009 at 18:43 UTC | |
by Corion (Patriarch) on Jul 23, 2009 at 18:51 UTC | |
by Anonymous Monk on Jul 23, 2009 at 18:54 UTC | |
|
Re: Moose + ORM
by Anonymous Monk on Jul 23, 2009 at 19:19 UTC | |
by stvn (Monsignor) on Jul 23, 2009 at 21:12 UTC | |
by stvn (Monsignor) on Jul 23, 2009 at 21:16 UTC | |
by Anonymous Monk on Jul 24, 2009 at 12:58 UTC | |
by stvn (Monsignor) on Jul 24, 2009 at 17:15 UTC | |
| |
by metaperl (Curate) on Jul 24, 2009 at 12:57 UTC | |
by Anonymous Monk on Jul 24, 2009 at 13:45 UTC | |
|
Re: Moose + ORM
by metaperl (Curate) on Jul 24, 2009 at 15:45 UTC | |
by Corion (Patriarch) on Jul 24, 2009 at 15:47 UTC | |
by Anonymous Monk on Jul 24, 2009 at 20:42 UTC | |
by Anonymous Monk on Jul 31, 2009 at 19:05 UTC |