At a first rough glance it looks like you are doing fine. I have questions about the interface, though. It seems like a lot of wordage just to make a simple query. Have you considered letting the method calls return the object?
# instead of this $select = new SQL::Builder::Select; $select->column('col1', 'col2'); $select->table('table'); $select->order_by('col1'); $select->limit_value('10'); $select->limit_offset('10'); ########## # you could do this: $select = new SQL::Builder::Select; $select->column('col1','col2') ->table('table') ->order_by('col1') ->limit_value('10') ->limit_offset('10');
It may be something worth considering, although I'm sure you have your reasons for having the interface like it is.

I've tried doing similar automagic query generation like this before, and in general it can get very ugly no matter how hard you try, with stuff like this: where_ne_or, where_gt_or, etc... You have to find your own balance between simplicity of interface and the domain of queries which you want to be able to represent.

One other thing I've noticed is that I don't see any provision for column aggregates like count() and max() and friends, in fact any SQL functions! Right now your module is a powerful logic combinator (just ANDs and ORs). But think about whether (and how) you want to represent queries like

select count(*) from polygons where sin(angle1)>(width*height)
By all means, you don't have to have provisions in your module to make these queries, but it might be beneficial to think about more common queries that are more than just AND/OR combinations.

Update: Come to think of it, you have a lot of similar code in the where_* methods -- you may want to consider using AUTOLOAD for these.

blokhead


In reply to Re: sql builder module - feedback request by blokhead
in thread sql builder module - feedback request by fireartist

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.