You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accessing backlinks from inside a query would be expected to either throw (unsupported) or succeed, but instead it silently fails, ignoring that portion of the query and returning unwanted results.
As an aside, my goal here is to iterate over a potentially large table to truncate rows with no backlinks (while also performing external tasks). I've found that just looping over every entry in the table and checking BacklinksCount works quite well, but if there's a more performant way of handling this kind of scenario I'd love to hear it. Looping looks to take around 4s for 1m entries.
Repro steps
Attempt to query a property marked with [Backlink] inside an IQueryable<> realm source.
Note that the backlink condition is completely ignored, returning all results.
Version
10.5.0
What SDK flavour are you using?
Local Database only
What type of application is this?
Console/Server
Client OS and version
macOS 15 beta
Code snippets
using System;using System.Linq;using Nito.AsyncEx;using Realms;using Xunit;namespace osu.Game.Tests
{publicclassBacklinkViaQueryBugTests{[Fact]publicvoidTestBacklinkViaQuery(){
AsyncContext.Run(()=>{// test with no backlinksusing(varrealm= Realm.GetInstance(new InMemoryConfiguration("a"))){using(vartransaction= realm.BeginWrite()){ realm.Add(new TestFile {Hash="1"}); transaction.Commit();}varfilesList= realm.All<TestFile>().ToList();// non-queryable so we can linq access BacklinksCount. Assert.Equal(0, filesList.Count(f => f.BacklinksCount >0)); Assert.Equal(0, realm.All<TestFile>().Count(f => f.Usages.Any()));}});}publicclassTestThingUsingFile:RealmObject{publicTestFileFile{get;set;}=null!;}publicclassTestFile:RealmObject{[PrimaryKey]publicstringHash{get;set;}= String.Empty;[Backlink(nameof(TestThingUsingFile.File))]publicIQueryable<TestThingUsingFile> Usages {get;}=null!;// TODO: check efficiency (ie. do we need to cache this to a count still?)}}}
Stacktrace of the exception/crash you're getting
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered:
Unfortunately, this is not yet supported by the current LINQ engine. If you are fine with using the string-based API, you should be able to .Filter("Usages.@count > 0).Count().
Main thing I wanted to bring up here was that it is silently ignored, which can actually cause very unexpected behaviours. Having it throw would be optimal (similar to other unsupported cases).
That is indeed very surprising and I don't have an explanation for why the query engine doesn't complain about the query being unsupported. Definitely something we'll try to repro and guard against, but it'll need to wait until next week.
What happened?
Accessing backlinks from inside a query would be expected to either throw (unsupported) or succeed, but instead it silently fails, ignoring that portion of the query and returning unwanted results.
As an aside, my goal here is to iterate over a potentially large table to truncate rows with no backlinks (while also performing external tasks). I've found that just looping over every entry in the table and checking
BacklinksCount
works quite well, but if there's a more performant way of handling this kind of scenario I'd love to hear it. Looping looks to take around 4s for 1m entries.Repro steps
[Backlink]
inside anIQueryable<>
realm source.Version
10.5.0
What SDK flavour are you using?
Local Database only
What type of application is this?
Console/Server
Client OS and version
macOS 15 beta
Code snippets
Stacktrace of the exception/crash you're getting
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: