I've been working on a hack against SQL::Translator::Schema to create schemas with a little less keystrokes. tables(), fields(), procedures(), etc change the scope of the objects returned, and all of the other properties like data_type(), size(), name(), nullable(), primary(), etc return $self to perpetuate the the current object.

my $schema = SQL::Translator::RecursiveSchema->new(name=>'MySchema'); $schema->tables('NewTable')->fields('id')->type('varchar')->size(36)-> +nullable(0); # instead of... my $field = $schema->get_table('NewTable')->get_field('id'); $field->size(36); $field->type('varchar'); $field->nullable(0);

This was inspired by a post about hacking the same into HTML::Element.

I wouldn't mind dumping it up on CPAN, but the name for such a beast is elusive to me...::RecursiveSchema, ::ChainedSchema, or something completely different. While it probably belongs in the SQL::Translator namespace, I don't want to invade that namespace if I don't have too. Anyone have any altername naming ideas?

-=Chris

20050809 Unconsidered by Corion (Keep/Edit/Delete: 7/3/0). Was considered by holli for moving to Meditations


In reply to Evil SQL::Translator::Schema Hack by jk2addict

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.