-
Notifications
You must be signed in to change notification settings - Fork 877
Make range and multirange opt-int to help with AOT size #4899
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
4d4b77c to
b0bebcd
Compare
c7026df to
9a14eb3
Compare
9a14eb3 to
a6e2a9a
Compare
a6e2a9a to
50029f2
Compare
50029f2 to
234618b
Compare
roji
left a 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.
BTW I wonder if it doesn't make sense also split multiranges into their own opt-in resolver, with the logic that using them is maybe even more rare than using ranges.
234618b to
69fec32
Compare
| }; | ||
| } | ||
|
|
||
| static DateTimeKind GetRangeKind(NpgsqlRange<DateTime> range) |
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 really don't like the fact that BuildInTypeHandlerResolver still references ranges, but without that it's going to make mapping quite difficult (you would have to add range resolver on GlobalTypeMapper) 😭
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.
Wouldn't adding the range resolver to GlobalTypeMapper undo what this PR is trying to do, i.e. allow all the range stuff to get trimmed? If we did that, all the ranges/range handlers would become visible again via the GlobalTypeMapper...
Yeah, this is a crappy situation, but it's a result of us having to resolve mapping stuff on NpgsqlParameter without having an actual connection (e.g. in "static" context); this has always been a pain.
We can consider breaking this, and making the getters on NpgsqlParameter (DbType, NpgsqlDbType, DataTypeName) work only if the parameter is attached to a command and through that to a connection (which has a type mapper). Or we could have a minimum, "default" mapping list on GlobalTypeMapper which doesn't include the ranges, and if the parameter is attached to a connection, go to its resolvers. This way, if you've opted into ranges on your data source, NpgsqlParameter.NpgsqlDbType will know about it, otherwise it won't.
Maybe open a separate issue for thinking about it?
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.
Wouldn't adding the range resolver to GlobalTypeMapper undo what this PR is trying to do, i.e. allow all the range stuff to get trimmed? If we did that, all the ranges/range handlers would become visible again via the GlobalTypeMapper...
Not exactly. We don't need to return a handler from GlobalTypeMapper, just an ability to resolve a mapping by value. We pretty much only need:
Dictionary<string, TypeMappingInfo>(where string isdataTypeName)Dictionary<Type, string>(where string isdataTypeName)ValueDependentValueToDataTypeName(and that's because of DataTime.Kind, where we can return either tstzrange or tsrange)
Maybe open a separate issue for thinking about it?
Yeah, sure.
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.
Not exactly. We don't need to return a handler from GlobalTypeMapper, just an ability to resolve a mapping by value.
Hmm.. Right, I remember now that GlobalTypeMapper only deals with type handler factories (which also manage the "static" global mappings). But adding the range resolver factory to the global mapper would also make it available for actually creating the resolver, which is where the trimming problems come in.
We could refactor to split the static mapping thing from the resolver factory (it's a bit ugly that both functions are combined in the factory anyway). At that point we can always add the range global mapping resolver (or whatever we call it), but not have a resolver factory for it without the opt-in...
Anyway, I think it's OK to deal with it after this PR.
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.
Anyway, I think it's OK to deal with it after this PR.
Yeah, we should think about this later.
roji
left a 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.
LGTM but see the unresolved comments
Closes #4898