} elsif (lc($op) eq '= any') {
$val = $$val[0] if (ref($val) eq 'ARRAY');
$val = $val->toSQL;
- $sql = "$val = ANY (".$self->SUPER::toSQL.")";
+ if ($rel && $rel->is_nullable) { # need to redo this
+ $sql = "((". $self->SUPER::toSQL .") IS NULL OR ";
+ } else {
+ $sql = '';
+ }
+ $sql .= "$val = ANY (".$self->SUPER::toSQL.")";
} elsif (lc($op) eq '<> any') {
$val = $$val[0] if (ref($val) eq 'ARRAY');
$val = $val->toSQL;
- $sql = "$val <> ANY (".$self->SUPER::toSQL.")";
+ if ($rel && $rel->is_nullable) { # need to redo this
+ $sql = "((". $self->SUPER::toSQL .") IS NULL OR ";
+ } else {
+ $sql = '';
+ }
+ $sql .= "$val <> ANY (".$self->SUPER::toSQL.")";
} elsif (lc($op) eq 'is blank') {
- $sql = '('. $self->SUPER::toSQL ." IS NULL OR ". $self->SUPER::toSQL ." = '')";
+ if ($rel && $rel->is_nullable) { # need to redo this
+ $sql = "((". $self->SUPER::toSQL .") IS NULL OR ";
+ } else {
+ $sql = '';
+ }
+ $sql .= '('. $self->SUPER::toSQL ." IS NULL OR ". $self->SUPER::toSQL ." = '')";
} elsif (lc($op) eq 'is not blank') {
- $sql = '('. $self->SUPER::toSQL ." IS NOT NULL AND ". $self->SUPER::toSQL ." <> '')";
+ if ($rel && $rel->is_nullable) { # need to redo this
+ $sql = "((". $self->SUPER::toSQL .") IS NULL OR ";
+ } else {
+ $sql = '';
+ }
+ $sql .= '('. $self->SUPER::toSQL ." IS NOT NULL AND ". $self->SUPER::toSQL ." <> '')";
} elsif (lc($op) eq 'between') {
$sql .= " BETWEEN ". join(" AND ", map { $_->toSQL } @$val);