Code Monkey home page Code Monkey logo

Comments (9)

sedovalx avatar sedovalx commented on July 20, 2024

The problem is here

fun <S : XdEntity, T : XdEntity> XdQuery<S>.mapDistinct(dbFieldName: String, targetEntityType: XdEntityType<T>): XdQuery<T> {
    return queryEngine.selectDistinct(entityIterable, dbFieldName).asQuery(targetEntityType)
}

The QueryEngine here can return null elements in the resulting iterable. There is no way to predict if the result will contain null or not from the parameters of the function.

Another option would be to create nullable XdQuery<T : XdEntity, E : Entity?>, but it would be a bigger breaking change.

Probably, we should guard the XdQuery#entityIterable somehow.

from xodus-dnq.

lehvolk avatar lehvolk commented on July 20, 2024

Let's take a look how can we do it smarter.

from xodus-dnq.

lehvolk avatar lehvolk commented on July 20, 2024

Another thing here that worries me is that query.size() and query.asSequence().size may differs.

from xodus-dnq.

sedovalx avatar sedovalx commented on July 20, 2024

No nulls - no problems, right? We may change the mapDistinct to ignore null results at all, but I personally dislike this not obvious behavior. Though, we can make it more clear:

  • make XdQuery#entityIterable elements not nullable again
  • create a mapNotNull method that ignores null results
  • make mapDistinct to use mapNotNull
  • deprecate mapDistinct method in favor to the mapNotNull
  • remove XdQuery#asNullableSequence method

p.s.: mapDistinctNotNull/ mapNotNullDistinct?

from xodus-dnq.

lehvolk avatar lehvolk commented on July 20, 2024

Let's discuss nulls in EntityIterable with @penemue when he will be back. At the current moment seems that nulls may appear only on mapDistinct, flatMapDistinct operations.

from xodus-dnq.

penemue avatar penemue commented on July 20, 2024

Nulls can be among the results of SelectDistinct or SelectManyDistinct.

from xodus-dnq.

lehvolk avatar lehvolk commented on July 20, 2024

@penemue am I right that result of querying EntityIterable with nulls will be EntityIterable without nulls?

from xodus-dnq.

mazine avatar mazine commented on July 20, 2024

OK guys. After all discussions I think that we don't need Iterable<Entity?> at all. Yes, it means that it will be impossible to have nulls returned by mapDistinct. I don't feel that we actually need it.

from xodus-dnq.

mazine avatar mazine commented on July 20, 2024

I'm rolling back all changes related to Iterable<Entity?>. I will add ExcludeNullStaticTypedEntityIterable to mapDistinct / flatMapDistinct.

from xodus-dnq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.