X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser%2FPostgreSQL.pm;h=37f657996b5d2b50bbbcbb4d76a64965463dbf0c;hb=HEAD;hp=ce3cfbb05a18f640de2a599cca6889c8a5af0193;hpb=9da488f2cb6a409bd3bb418a61a746ad274b8ccc;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Parser/PostgreSQL.pm b/lib/SQL/Translator/Parser/PostgreSQL.pm index ce3cfbb..37f6579 100644 --- a/lib/SQL/Translator/Parser/PostgreSQL.pm +++ b/lib/SQL/Translator/Parser/PostgreSQL.pm @@ -89,7 +89,7 @@ View table: use strict; use warnings; -our $VERSION = '1.59'; +our $VERSION = '1.62'; our $DEBUG; $DEBUG = 0 unless defined $DEBUG; @@ -247,7 +247,8 @@ create : CREATE unique(?) /(index|key)/i index_name /on/i table_id using_method( supertype => $item{'unique'}[0] ? 'constraint' : 'index', type => $item{'unique'}[0] ? 'unique' : 'normal', fields => $item[9], - method => $item{'using_method'}[0], + method => $item{'using_method(?)'}[0], + where => $item{'where_predicate(?)'}[0], } ; } @@ -613,11 +614,16 @@ pg_data_type : $return = { type => 'bytea' }; } | - /(timestamptz|timestamp)(?:\(\d\))?( with(?:out)? time zone)?/i + / ( timestamp (?:tz)? ) (?: \( \d \) )? ( \s with (?:out)? \s time \s zone )? /ix { $return = { type => 'timestamp' . ($2||'') }; } | + / ( time (?:tz)? ) (?: \( \d \) )? ( \s with (?:out)? \s time \s zone )? /ix + { + $return = { type => 'time' . ($2||'') }; + } + | /text/i { $return = { @@ -626,7 +632,7 @@ pg_data_type : }; } | - /(bit|box|cidr|circle|date|inet|line|lseg|macaddr|money|numeric|decimal|path|point|polygon|timetz|time|varchar|json|hstore)/i + /(bit|box|cidr|circle|date|inet|line|lseg|macaddr|money|numeric|decimal|path|point|polygon|varchar|json|hstore|uuid)/i { $return = { type => $item[1] }; } @@ -1000,14 +1006,18 @@ SET : /set/i NAME : DQSTRING | /\w+/ -DQSTRING : '"' /((?:[^"]|"")+)/ '"' - { ($return = $item[2]) =~ s/""/"/g; } +DQSTRING : '"' /((?:[^"]|"")+)/ '"' + { ($return = $item[3]) =~ s/""/"/g; } + +SQSTRING : "'" /((?:[^']|'')*)/ "'" + { ($return = $item[3]) =~ s/''/'/g } -SQSTRING : "'" /((?:[^']|'')*)/ "'" - { ($return = $item[2]) =~ s/''/'/g } +DOLLARSTRING : /\$[^\$]*\$/ /.*?(?=\Q$item[1]\E)/s "$item[1]" + { $return = $item[3]; } VALUE : /[-+]?\d*\.?\d+(?:[eE]\d+)?/ | SQSTRING + | DOLLARSTRING | /null/i { 'NULL' } @@ -1075,10 +1085,14 @@ sub parse { } for my $idata ( @{ $tdata->{'indices'} || [] } ) { + my @options = (); + push @options, { using => $idata->{'method'} } if $idata->{method}; + push @options, { where => $idata->{'where'} } if $idata->{where}; my $index = $table->add_index( - name => $idata->{'name'}, - type => uc $idata->{'type'}, - fields => $idata->{'fields'}, + name => $idata->{'name'}, + type => uc $idata->{'type'}, + fields => $idata->{'fields'}, + options => \@options ) or die $table->error . ' ' . $table->name; }