Promote resolve_relationship_condition to a 1st-class API method
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / SQLMaker / OracleJoins.pm
index fe9bd07..00e58fb 100644 (file)
@@ -81,8 +81,8 @@ sub _recurse_oracle_joins {
     }
 
     # FIXME - the code below *UTTERLY* doesn't work with custom conds... sigh
-    # for the time being do not do any processing with the likes of _collapse_cond
-    # instead only unroll the -and hack if present
+    # for the time being do not do any processing with the likes of
+    # normalize_sqla_condition(), instead only unroll the -and hack if present
     $on = $on->{-and}[0] if (
       ref $on eq 'HASH'
         and
@@ -93,13 +93,22 @@ sub _recurse_oracle_joins {
       @{$on->{-and}} == 1
     );
 
-    # sadly SQLA treats where($scalar) as literal, so we need to jump some hoops
-    push @where, map { \sprintf ('%s%s = %s%s',
-      ref $_ ? $self->_recurse_where($_) : $self->_quote($_),
-      $left_join,
-      ref $on->{$_} ? $self->_recurse_where($on->{$_}) : $self->_quote($on->{$_}),
-      $right_join,
-    )} keys %$on;
+
+    push @where, map { \do {
+        my ($sql) = $self->_recurse_where({
+          # FIXME - more borkage, more or less a copy of the kludge in ::SQLMaker::_join_condition()
+          $_ => ( length ref $on->{$_}
+            ? $on->{$_}
+            : { -ident => $on->{$_} }
+          )
+        });
+
+        $sql =~ s/\s*\=/$left_join =/
+          if $left_join;
+
+        "$sql$right_join";
+      }
+    } sort keys %$on;
   }
 
   return { -and => \@where };