query = (MongoDBQueryDescriptor) customQuery.getQueryObject();
}
// a string-based native query; need to create the DBObject from that
else {
// TODO OGM-414 This should actually be cached in the native query plan
NativeQueryParser parser = Parboiled.createParser( NativeQueryParser.class );
ParsingResult<MongoDBQueryDescriptorBuilder> parseResult = new RecoveringParseRunner<MongoDBQueryDescriptorBuilder>( parser.Query() ).run( customQuery.getQueryString() );
if (parseResult.hasErrors() ) {
throw new IllegalArgumentException( "Unsupported native query: " + ErrorUtils.printParseErrors( parseResult.parseErrors ) );
}
query = parseResult.resultValue.build();