From: Matt S Trout Date: Sat, 14 Apr 2012 02:54:16 +0000 (+0000) Subject: add more attributes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4cea30e6c3d85b444f106d26fd6398110350fa1b;hp=8b4289c84d8ac962d79eba63f795ff440aff309b;p=dbsrgits%2FData-Query.git add more attributes --- diff --git a/lib/Data/Query/Renderer/SQL/Naive.pm b/lib/Data/Query/Renderer/SQL/Naive.pm index 31cd462..1da16b9 100644 --- a/lib/Data/Query/Renderer/SQL/Naive.pm +++ b/lib/Data/Query/Renderer/SQL/Naive.pm @@ -19,8 +19,14 @@ has reserved_ident_parts => ( has quote_chars => (is => 'ro', default => sub { [''] }); +has identifier_sep => (is => 'ro', default => sub { '.' }); + has simple_ops => (is => 'ro', builder => '_default_simple_ops'); +has lc_keywords => (is => 'ro', default => sub { 0 }); + +has always_quote => (is => 'ro', default => sub { 0 }); + sub _default_simple_ops { +{ (map +($_ => 'binop'), qw(= > < >= <= != LIKE), 'NOT LIKE' ), @@ -70,7 +76,7 @@ sub _flatten_structure { # # FEH. -sub _format_keyword { $_[0]->{lc_keywords} ? lc($_[1]) : $_[1] } +sub _format_keyword { $_[0]->lc_keywords ? lc($_[1]) : $_[1] } sub _render { $_[0]->${\"_render_${\(lc($_[1]->{type})||'broken')}"}($_[1]); @@ -87,11 +93,11 @@ sub _render_identifier { unless my @i = @{$_[1]->{elements}}; # handle single or paired quote chars my ($q1, $q2) = @{$_[0]->quote_chars}[0,-1]; - my $always_quote = $_[0]->{always_quote}; + my $always_quote = $_[0]->always_quote; my $res_check = $_[0]->reserved_ident_parts; return [ join - $_[0]->{identifier_sep}||'.', + $_[0]->identifier_sep, map +( $_ eq '*' # Yes, this means you can't have a column just called '*'. ? $_ # Yes, this is a feature. Go shoot the DBA if he disagrees.