[Dbix-class] Explicit ASTs (ping nate)

Matt S Trout dbix-class at trout.me.uk
Sat Sep 2 23:48:44 CEST 2006


Ash Berlin wrote:
> Matt S Trout wrote:
>>    SELECT my.a, my.b FROM my_table my WHERE spork = 1
>>
>> and that would become
>>
>>    {
>>      select => [ [ -name, 'my', 'a' ], [ -name, 'my', 'b' ] ],
>>      from => [ [ -alias, 'my_table', 'my' ] ],
>>      where => [ [ -op, '=', [ -name, 'spork' ], [ -bind, 1 ] ] ],
>>    }
>>
>> which is ... spectacularly ugly, but I -think- explicit enough. 
> [snip]
> 
> No kidding thats ugly. Would there be shortcuts for common operations 
> (maybe just in DBIC, not SQL::A itself) such as just `select these 
> cols'? such as:

No. The whole point of this is it's the *explicit* syntax in the middle that 
the DWIM syntax gets parsed to, it's optimised for interaction from code, not 
for being written by a human - because there's only one way of expressing 
something we can reason across a tree like this much more easily than we can 
the current syntax (i.e. this should probably buy us a clean way to implement 
auto-joins with the syntax Sweet supports)

SQL::Abstract would end up providing a parser for its current syntax that 
emits this to a second object that generates the SQL from it, and other query 
syntax modules could also generate this AST to provide Tangram-style or whatever.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list