question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Array of Primitives: Support queries

See original GitHub issue

Split from https://github.com/realm/realm-java/pull/5031

We need to add support for arrays of values to RealmQuery. Based on API discussions we don’t want to add a ton of extra methods, so instead we are going to use the empty field name "" when querying arrays of primitives.

E.g

public class Person extends RealmObject {
  public RealmList<String> names;
}

// Query list in object
RealmResults<Person> results =  realm.where(Person.class).equalTo("names", "John").findAll();

This also include support for RealmList.min()/max()/average()/sum()/minDate()/maxDate() which depends on the query system

Out of scope for now

// Query list directly
Person p = getPerson();
RealmResults<String> results = p.names.where().like("", "Jo*").findAll();

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:12
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
aritrobanerjee93commented, Jul 25, 2019

Hi, Any update on this much needed feature? It’s 2019 and I don’t think using a wrapper seems agreeable anymore. If anyone has a workaround apart from flatlists, I would love to learn!

5reactions
Zhuindencommented, Apr 27, 2018

@mgohin another option of course is to map the list into a single string field with some convention like |value1|value2|value3| and then contains("flatList", "|${searchValue}|")

But that’s lame that we still have to do that, i agree

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chronicle Map support for arrays of primitives? - Stack Overflow
1 Answer 1 ... Chronicle Values are designed as constant-sized structures. If you need to store some variable-sized fields e. g. CharSequences ( ......
Read more >
Array Initialization | Java Operators with Primitives and Objects
Arrays of primitives have elements that are initialized to default values. Arrays of objects have the value null in each element. You are ......
Read more >
Is an array a primitive type or an object in Java?
In Java programming language, arrays are objects which are dynamically created, and may be assigned to variables of type Object. All methods of ......
Read more >
Array Data Types - int Array, Double array, Array of Strings Etc.
This tutorial will walk you through Java arrays with different data types and discuss their usage in Java programs through simple examples.
Read more >
Execute a Query that Returns a Primitive Type - Documentation
Documentation about How to: Execute a Query that Returns a Primitive Type in Data Access Classic. Get the help you need online.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found