-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix the QueriesDocument and the Queries UI #16402
Conversation
Why is splitting Queries into multiple documents necessary for the fix? Also, please fix the build. |
@Piedone The problem with today's approach is that it stores all different query types in the same document. So when we add, update or remove a query, we serialize/deserialize the entire document. For this to work with STJ, we have to register each query type with the base type. When the feature is disabled after a query is added to the document, we get an exception because the derived type is no longer registered with the base type. For example, if you enable the Sql feature, then add a SqlQuery using the UI. Now enable Lucene feature and disable the Sql feature. Visiting the queries UI will throw exception because the document has a record serialized to SqlQuery but there is no map between SqlQuery to Query. To solve this problem, we agreed to remove the document manager during last meeting and instead to store each query as a document. This way we fix the issue and also avoid using the document manager or worry about registering additional types. |
Wow, what an effort. I knew why I left this to you 🤗 |
src/OrchardCore.Modules/OrchardCore.Queries/Sql/GraphQL/SqlQueryFieldTypeProvider.cs
Outdated
Show resolved
Hide resolved
I see, thanks for explaining! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll resume reviewing this in-depth once the exception is fixed. Also, please fix the tests.
src/OrchardCore.Modules/OrchardCore.Queries/Controllers/AdminController.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
@Piedone the test should now pass. Feel free to check out the code changes. |
src/OrchardCore/OrchardCore.Queries.Core/Services/DefaultQueryManager.cs
Show resolved
Hide resolved
Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you like to check the code again, @gvkries?
@gvkries this is the last PR that is blocking the release of 2. Do you have any additional feedback on this PR? Or, should we merge it? Thank you |
Sorry, didn't had time the last couple of days. I will check ASAP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
services.AddScoped<INavigationProvider, AdminMenu>(); | ||
services.AddScoped<SqlQuerySource>(); | ||
services.AddScoped<IQuerySource>(sp => sp.GetService<SqlQuerySource>()); | ||
services.AddKeyedScoped<IQuerySource>(SqlQuerySource.SourceName, (sp, key) => sp.GetService<SqlQuerySource>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add an extension method for registering an IQuerySource
, it's already repeated several times here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@gvkries I can’t seems to be able to reproduce that query not saving issue. Are you sure you are using the latest code? |
I think so. Just create an new site with the blog recipe, go to Queries -> Edit and the SQL query gets deleted instead of modified. |
Co-authored-by: Georg von Kries <gvk@creativbox.net>
@gvkries I was finally able to reproduce the issue and fix it. Can you please confirm? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @MikeAlhayek
Fix #16372
/cc @sebastienros @gvkries