Comments (9)
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.
Let's take a look how can we do it smarter.
from xodus-dnq.
Another thing here that worries me is that query.size()
and query.asSequence().size
may differs.
from xodus-dnq.
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 usemapNotNull
- deprecate
mapDistinct
method in favor to themapNotNull
- remove
XdQuery#asNullableSequence
method
p.s.: mapDistinctNotNull
/ mapNotNullDistinct
?
from xodus-dnq.
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.
Nulls can be among the results of SelectDistinct or SelectManyDistinct.
from xodus-dnq.
@penemue am I right that result of querying EntityIterable with nulls will be EntityIterable without nulls?
from xodus-dnq.
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.
I'm rolling back all changes related to Iterable<Entity?>
. I will add ExcludeNullStaticTypedEntityIterable
to mapDistinct
/ flatMapDistinct
.
from xodus-dnq.
Related Issues (20)
- Dependencies not released HOT 3
- Conditionally required properties are not checked when they are not changed but their condition becomes true
- TransientChangesTrackerImpl#linksRemoved marks entity as modified even if there were actually no links removed
- Implement equals/hashCode for TransientEntityChange HOT 1
- Missing methods: XdQuery<T>.last(), XdQuery<T>.lastOrNull()
- Error when using XdEnumEntityType HOT 3
- TransientSession looses cancelling policy on upgrading initial read-only txn
- Cache entity wrappers inside XdModel.toXd() HOT 1
- One have to manually close Environment on closing TransientEntityStore
- Concurrent access to TransientEntityStoreImpl#listeners
- Make it possible to disable async listeners per enviroment
- Migration / versions of data definitions HOT 2
- DSL support for EntityIterable.findContaining(...)
- GraalVM/Spring Native Compatibility HOT 2
- UUID type support HOT 1
- xodus-dnq is incompatible with newer Java versions (tested on Java 16) HOT 2
- Make SingletonEntitiesCache store container aware
- Sample program fails with "java.lang.reflect.InaccessibleObjectException"
- java.lang.ClassCastException: class kotlinx.dnq.util.FakeEntity cannot be cast to class jetbrains.exodus.database.TransientEntity HOT 1
- Design of the storage engine
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xodus-dnq.