+sub QueryToSQL {
+ my $self = shift;
+ my $query = shift || $self->Argument;
+
+ my %limits;
+ $query =~ s/^\s*//;
+ while ($query =~ /^\S/) {
+ if ($query =~ s/^
+ (?:
+ (\w+) # A straight word
+ (?:\. # With an optional .foo
+ ($RE{delimited}{-delim=>q['"]}
+ |[\w-]+ # Allow \w + dashes
+ ) # Which could be ."foo bar", too
+ )?
+ )
+ : # Followed by a colon
+ ($RE{delimited}{-delim=>q['"]}
+ |\S+
+ ) # And a possibly-quoted foo:"bar baz"
+ \s*//ix) {
+ my ($type, $extra, $value) = ($1, $2, $3);
+ ($value, my ($quoted)) = $self->Unquote($value);
+ $extra = $self->Unquote($extra) if defined $extra;
+ $self->Dispatch(\%limits, $type, $value, $quoted, $extra);
+ } elsif ($query =~ s/^($RE{delimited}{-delim=>q['"]}|\S+)\s*//) {
+ # If there's no colon, it's just a word or quoted string
+ my($val, $quoted) = $self->Unquote($1);
+ $self->Dispatch(\%limits, $self->GuessType($val, $quoted), $val, $quoted);