Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Like Crash #3462

Closed
carbonete opened this issue Oct 24, 2023 · 2 comments
Closed

Like Crash #3462

carbonete opened this issue Oct 24, 2023 · 2 comments

Comments

@carbonete
Copy link

What happened?

Made LIKE without any wildcard, this crash occurs.

Repro steps

Please , See snippet

Version

11.5.0

What Atlas Services are you using?

Both Atlas Device Sync and Atlas App Services

What type of application is this?

Xamarin

Client OS and version

IOS 17 - Emulator

Code snippets

lke = "b";
foreach (Verb v in verbInstance.Where(v => QueryMethods.Like(v.SearchText, lke.ToString(), false)))
{
ret.Add(new string[] { idiom, v.Text.ToString() });
}

Stacktrace of the exception/crash you're getting

2023-10-24 09:21:07.852982-0400 LexSemanticClient.iOS[21161:362096] System.NotSupportedException: The method 'Boolean Like(System.String, System.String, Boolean)' has to be invoked with a single string constant argument or closure variable
  at Realms.RealmResultsVisitor.VisitMethodCall (System.Linq.Expressions.MethodCallExpression node) [0x009c4] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Linq\RealmResultsVisitor.cs:445 
  at System.Linq.Expressions.MethodCallExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs:109 
  at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/ExpressionVisitor.cs:34 
  at Realms.Realm
ResultsVisitor.VisitMethodCall (System.Linq.Expressions.MethodCallExpression node) [0x00081] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Linq\RealmResultsVisitor.cs:205 
  at System.Linq.Expressions.MethodCallExpression.Accept (System.Linq.Expressions.ExpressionVisitor visitor) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs:109 
  at System.Linq.Expressions.ExpressionVisitor.Visit (System.Linq.Expressions.Expression node) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/ExpressionVisitor.cs:34 
  at Realms.RealmResults`1[T].GetOrCreateHandle () [0x0001f] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\Linq\RealmResults.cs:75 
  at System.Lazy`1[T].ViaFactory (System.Threading.LazyThreadSafetyMode mode) [0x00043] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:333 
  at System.Lazy`1[T].ExecutionAndPublication (System.LazyHelper executionAndPublication, System.Boolean useDefaultConstructor) [0x00022] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:351 
  at System.Lazy`1[T].CreateValue () [0x00074] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:431 
  at System.Lazy`1[T].get_Value () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:509 
  at Realms.RealmCollectionBase`1[T].get_IsValid () [0x00000] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:111 
  at Realms.RealmCollectionBase`1+Enumerator[T]..ctor (Realms.RealmCollectionBase`1[T] parent) [0x0000d] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm
\DatabaseTypes\RealmCollectionBase.cs:543 
  at Realms.RealmCollectionBase`1[T].GetEnumerator () [0x00000] in D:\a\realm-dotnet\realm-dotnet\Realm\Realm\DatabaseTypes\RealmCollectionBase.cs:410 
  at LexSemanticDicPersistence.Services.LexSemanticDicService.SearchLenghOrMask (System.String dbname, System.String lke) [0x000cc] in Service.cs:262

Relevant log output

No response

@meierhoeferjannis
Copy link

I'm not an Expert on in Realm, but I think the Problem is the Ike.ToString() call. I guess you have to use constant values in realm queries as I experienced the same behavior for normal Queries without the Like Operator.
For Example
verbInstance.Where(v => QueryMethods.Like(v.SearchText, "hello", false))
would work because hello is constant string. I think what you could do in your case would be something like:
var searchParam = Ike.ToString();
verbInstance.Where(v => QueryMethods.Like(v.SearchText,searchParam , false));

Hope that helps :) Otherwise the realm team needs to take care of the issue :)

@papafe
Copy link
Contributor

papafe commented Oct 30, 2023

@meierhoeferjannis is correct here, you should use a constant or a variable as your second argument.

This should solve your issue. I'm closing this ticket for now, but feel free to reopen it if this doesn't answer your question.

@papafe papafe closed this as completed Oct 30, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants