From 1d23e874281ba111d5cf37c7aef76d45d25a5170 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 21 Oct 2007 00:46:26 +0000 Subject: Allow open exists filter to operate on many-to-one join. --- .../amazon/carbonado/cursor/FilteredCursorGenerator.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/cursor') diff --git a/src/main/java/com/amazon/carbonado/cursor/FilteredCursorGenerator.java b/src/main/java/com/amazon/carbonado/cursor/FilteredCursorGenerator.java index 745ad7a..04ea2e8 100644 --- a/src/main/java/com/amazon/carbonado/cursor/FilteredCursorGenerator.java +++ b/src/main/java/com/amazon/carbonado/cursor/FilteredCursorGenerator.java @@ -349,6 +349,17 @@ class FilteredCursorGenerator { } public Object visit(ExistsFilter filter, Object param) { + // Load join property value to stack. + CodeBuilder b = mIsAllowedBuilder; + loadChainedProperty(b, filter.getChainedProperty()); + + if (!filter.getChainedProperty().getLastProperty().isQuery()) { + // Checking for existence or non-existence of many-to-one join. + // Implement by comparing against null. + getScope().successIfNullElseFail(b, filter.isNotExists()); + return null; + } + // Recursively gather all the properties to be passed to sub-filter. final List subPropFilters = new ArrayList(); @@ -364,10 +375,6 @@ class FilteredCursorGenerator { } }, null); - // Load join property value to stack. It is expected to be a Query. - CodeBuilder b = mIsAllowedBuilder; - loadChainedProperty(b, filter.getChainedProperty()); - final TypeDesc queryType = TypeDesc.forClass(Query.class); // Refine Query filter, if sub-filter isn't open. -- cgit v1.2.3