JetBrains/xodus-dnq

XdQuery.mapDistinct is not working for optional fields

lehvolk opened this issue · 4 comments

queryEngine.selectDistinct can return collection with null values inside but XdQuery treated all values inside as not-null therefore iterating of XdQuery will fail.

As I see there are few possibilities to fix it:

  • make XdQuery parametrisation optional <T?>
  • wrap result of selectDistinct into ExcludeNullStaticTypedEntityIterable

@mazine @sedovalx what do you think of it?

Can you give an example when nulls are valid values?

@sedovalx just run this code and get exception

        val boss = store.transactional {
            User.new {
                login = "boss"
                skill = 1
            }
        }
        store.transactional {
            User.new {
                login = "slave"
                supervisor = boss
                skill = 1
            }
        }
        store.transactional {
            User.all().mapDistinct(User::supervisor).asSequence().forEach {
                println(it.login)
            }
        }

@lehvolk take a look at the sedovalx@e8ab689