Skip to content

Please use the "contains element" condition instead for property "elementIds"; the plain "contains"condition is deprecated for string containers and will be removed in a future version #481

@techouse

Description

@techouse

Basic info:

  • ObjectBox version: 1.6.2
  • Flutter/Dart SDK: Dart 2.18.2 + Flutter 3.3.5
  • Null-safety enabled: yes
  • Reproducibility: always
  • OS: macOS 12.6
  • Device: iPhone 13 Pro MAX running iOS 16.0.3

Steps to reproduce

  1. Create a class field like
@Entity()
MyClass {
  MyClass({
    this.elementIds,
  });

  List<String> elementIds;
}
  1. Query that field using
final List<MyClass> items = myClassBox.query(
    MyClass_.elementIds.contains('some_id'),
  ).build().find();
  1. Run on an iPhone
  2. See the deprecation message
[INFO ] Please use the "contains element" condition instead for property "elementIds"; 
the plain "contains"condition is deprecated for string containers and will be removed in a future version

Expected behavior

No deprecation warning.

I was expecting there to be some sort of "contains element" API for a List<String> but it doesn't seem so, as there is only

class QueryStringVectorProperty<EntityT>
    extends QueryProperty<EntityT, List<String>> {
  QueryStringVectorProperty(ModelProperty model) : super(model);

  Condition<EntityT> contains(String p, {bool? caseSensitive, String? alias}) =>
      _StringCondition<EntityT, List<String>>(
          _ConditionOp.contains, this, p, null, alias,
          caseSensitive: caseSensitive);
}

So that deprecation warning is kinda confusing.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions