Skip to content

Remove Filters.eqFull #1292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions driver-core/src/main/com/mongodb/client/model/Filters.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.mongodb.client.model;

import com.mongodb.annotations.Beta;
import com.mongodb.client.model.geojson.Geometry;
import com.mongodb.client.model.geojson.Point;
import com.mongodb.client.model.search.SearchCollector;
Expand Down Expand Up @@ -85,30 +84,11 @@ public static <TItem> Bson eq(@Nullable final TItem value) {
* @param <TItem> the value type
* @return the filter
* @mongodb.driver.manual reference/operator/query/eq $eq
* @see #eqFull(String, Object)
*/
public static <TItem> Bson eq(final String fieldName, @Nullable final TItem value) {
return new SimpleEncodingFilter<>(fieldName, value);
}

/**
* Creates a filter that matches all documents where the value of the field name equals the specified value.
* Unlike {@link #eq(String, Object)}, this method creates a full form of {@code $eq}.
* This method exists temporarily until Atlas starts supporting the short form of {@code $eq}.
* It will likely be removed in the next driver release.
*
* @param fieldName the field name
* @param value the value, which may be null
* @param <TItem> the value type
* @return the filter
* @mongodb.driver.manual reference/operator/query/eq $eq
* @since 4.11
*/
@Beta(Beta.Reason.SERVER)
public static <TItem> Bson eqFull(final String fieldName, @Nullable final TItem value) {
return new OperatorFilter<>("$eq", fieldName, value);
}

/**
* Creates a filter that matches all documents where the value of the field name does not equal the specified value.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public interface VectorSearchOptions extends Bson {
* {@link Aggregates#vectorSearch(FieldSearchPath, Iterable, String, long, long, VectorSearchOptions) queryVector}.
* One may use {@link Filters} to create this filter, though not all filters may be supported.
* See the MongoDB documentation for the list of supported filters.
* <p>
* Note that for now one has to use {@link Filters#eqFull(String, Object)} instead of {@link Filters#eq(String, Object)}.</p>
* @return A new {@link VectorSearchOptions}.
*/
VectorSearchOptions filter(Bson filter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import static com.mongodb.client.model.Aggregates.project;
import static com.mongodb.client.model.Aggregates.replaceWith;
import static com.mongodb.client.model.Filters.and;
import static com.mongodb.client.model.Filters.eqFull;
import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Filters.gt;
import static com.mongodb.client.model.Filters.gte;
import static com.mongodb.client.model.Filters.in;
Expand Down Expand Up @@ -292,14 +292,14 @@ void vectorSearchSupportedFilters() {
assertAll(
() -> asserter.accept(lt("year", 2016)),
() -> asserter.accept(lte("year", 2016)),
() -> asserter.accept(eqFull("year", 2016)),
() -> asserter.accept(eq("year", 2016)),
() -> asserter.accept(gte("year", 2016)),
() -> asserter.accept(gt("year", 2015)),
() -> asserter.accept(ne("year", 2016)),
() -> asserter.accept(in("year", 2000, 2016)),
() -> asserter.accept(nin("year", 2000, 2016)),
() -> asserter.accept(and(gte("year", 2015), lte("year", 2016))),
() -> asserter.accept(or(eqFull("year", 2015), eqFull("year", 2016)))
() -> asserter.accept(or(eq("year", 2015), eq("year", 2016)))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import static com.mongodb.client.model.Filters.bitsAnySet
import static com.mongodb.client.model.Filters.elemMatch
import static com.mongodb.client.model.Filters.empty
import static com.mongodb.client.model.Filters.eq
import static com.mongodb.client.model.Filters.eqFull
import static com.mongodb.client.model.Filters.expr
import static com.mongodb.client.model.Filters.geoIntersects
import static com.mongodb.client.model.Filters.geoWithin
Expand Down Expand Up @@ -78,12 +77,6 @@ class FiltersSpecification extends Specification {
toBson(eq(1)) == parse('{_id : 1}')
}

def 'should render eqFull'() {
expect:
toBson(eqFull('x', 1)) == parse('{x : {$eq: 1}}')
toBson(eqFull('x', null)) == parse('{x : {$eq: null}}')
}

def 'should render $ne'() {
expect:
toBson(ne('x', 1)) == parse('{x : {$ne : 1} }')
Expand Down
18 changes: 0 additions & 18 deletions driver-scala/src/main/scala/org/mongodb/scala/model/Filters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.mongodb.scala.model

import com.mongodb.annotations.Beta

import java.lang

import scala.collection.JavaConverters._
Expand Down Expand Up @@ -51,22 +49,6 @@ object Filters {
*/
def eq[TItem](fieldName: String, value: TItem): Bson = JFilters.eq(fieldName, value)

/**
* Creates a filter that matches all documents where the value of the field name equals the specified value.
* Unlike `Filters.eq`, this method creates a full form of `\$eq`.
* This method exists temporarily until Atlas starts supporting the short form of `\$eq`.
* It will likely be removed in the next driver release.
*
* @param fieldName the field name
* @param value the value
* @tparam TItem the value type
* @return the filter
* @see [[https://www.mongodb.com/docs/manual/reference/operator/query/eq \$eq]]
* @since 4.11
*/
@Beta(Array(Beta.Reason.SERVER))
def eqFull[TItem](fieldName: String, value: TItem): Bson = JFilters.eqFull(fieldName, value)

/**
* Allows the use of aggregation expressions within the query language.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ class FiltersSpec extends BaseSpec {
toBson(model.Filters.equal("x", null)) should equal(Document("""{x : null}"""))
}

it should "render eqFull" in {
toBson(model.Filters.eqFull("x", 1)) should equal(Document("""{x : {$eq: 1}}"""))
toBson(model.Filters.eqFull("x", null)) should equal(Document("""{x : {$eq: null}}"""))
}

it should "render $ne" in {
toBson(model.Filters.ne("x", 1)) should equal(Document("""{x : {$ne : 1} }"""))
toBson(model.Filters.ne("x", null)) should equal(Document("""{x : {$ne : null} }"""))
Expand Down