Skip to content

Commit

Permalink
Item10672: add test for hoising the simplified version, found one bug…
Browse files Browse the repository at this point in the history
… (failing) and a number of places where I need to try to stop if from generating JS

git-svn-id: http://svn.foswiki.org/trunk/MongoDBPlugin@11733 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed May 24, 2011
1 parent 74d136b commit ffa75d8
Show file tree
Hide file tree
Showing 2 changed files with 373 additions and 510 deletions.
14 changes: 13 additions & 1 deletion lib/Foswiki/Plugins/MongoDBPlugin/HoistMongoDB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ sub hoist {
$mongoDBQuery = { '$where' => convertToJavascript($mongoDBQuery) };
}

die $mongoDBQuery if ( ref($mongoDBQuery) eq '' );
if ( ref($mongoDBQuery) eq '' ) {
#node simplified() to hell?
return { '$where' => $mongoDBQuery };

}

#TODO: sadly, the exception throwing wasn't working so I'm using a brutish propogate error
if ( defined( $mongoDBQuery->{ERROR} ) ) {
Expand Down Expand Up @@ -1046,8 +1050,16 @@ sub hoistMongoDB {
else {
$lhs = $node->{params}[0]->{params}[0];
}

#the $node->simplify() makes a non-node mess of the parse tree
#lets see if its a hash, and the rhs is a key..
if ((ref( $lhs ) eq 'HASH') and (defined($lhs->{$rhs}))) {
return $lhs->{$rhs};
}

print STDERR "-------------------------------- hoist OP_dot("
. ref( $lhs ) . ", "
. ref( $rhs ) . ", "
. ref( $node->{op} ) . ", "
. Data::Dumper::Dumper($node) . ")\n"
if Foswiki::Plugins::MongoDBPlugin::HoistMongoDB::MONITOR;
Expand Down
Loading

0 comments on commit ffa75d8

Please sign in to comment.