-
Notifications
You must be signed in to change notification settings - Fork 934
Fix HQL and LINQ query by a type on <any/> with meta-types other than int #1803
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
Conversation
@@ -277,25 +278,29 @@ private void ProcessMetaTypeDiscriminatorIfNecessary(IASTNode lhs, IASTNode rhs) | |||
return; | |||
} | |||
|
|||
var lhsNodeMetaType = lhsNode.DataType as MetaType; | |||
if (lhsNodeMetaType != null) | |||
if (lhsNode.DataType is MetaType lhsNodeMetaType) |
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.
Having a quick look at it, it seems the same could be done with ClassMetaType
, which should allow supporting the Class
mapping case. Or am I missing something?
(Maybe ClassMetaType
should even extend MetaType
, with a hard-coded in base constructor call StringType
base type.)
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.
Well, the HQL test is invalid for that case, because class
meta-type asks for the full class name.
By the way there is a workaround for all HQL cases: using parameters. It seems this was considered as a known limitation of the any
mapping at some point, see this Jira comment.
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.
Adjusting the tests for HQL is really easy. But I was struggling with making a generic Linq change. So I just gave up. Anyway, IMO, ClassMetaType
is weird creature of a frankenstein: it was created as a compatibility layer. I really think it shall finally RIP.
@fredericDelaporte I think here we shall fix only what's been asked for (meta-type). Rest can be fixed later at some point, if we'll desire to do so. |
Gave it another try and I was able to make it work with for |
Great. I was still looking in all this. Currently, "implicit" is in fact equivalent to |
Ok, this broke an old test. |
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.
The "implicit" case will require another, maybe more impact-full, fix.
(I think the line 43 here:
nhibernate-core/src/NHibernate/Mapping/Any.cs
Lines 40 to 44 in c85d038
type = | |
new AnyType( | |
metaValues == null | |
? ("class".Equals(metaTypeName) ? new ClassMetaType(): TypeFactory.HeuristicType(metaTypeName)) | |
: new MetaType(metaValues, TypeFactory.HeuristicType(metaTypeName)), |
Needs to always yield an IMetaType
.)
Fixes #1774