-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
V7 IMemberSource Seems to not be used #3148
Comments
Nobody cared until you did:) Just got missed in the giant V7 LINQ rewrite work |
Why not pass queried parameters through the injected json serializer? So it will always match with the stored document? Instead of this interface that does basically the same. |
@JurJean Not all possible pg types have a direct equivalent json type. Date/time-like types are usually stored as some string in json, but you probably would want to treat them as some timestamp type when querying, so you would also need some casting/conversion logic wrapped around that conversion. |
@jeremydmiller is there currently any alternative way of supporting custom types in marten v7? Specifically, we have some strongly typed reference identifiers that for all intents and purposes should just be treated as If not, are there any plans or desires to support this again in the (hopefully near) future? EDIT: |
@CptWesley That's what IMemberSource is meant to do in the first place. The strong typed identifier stuff is still in the backlog, but it's not top of mind for me anytime soon tbh. I'd say that I'd be happy to take a pull request for that, but it's a ton of work that's going to take someone willing to get into internals. Just getting Marten to use IMemberSource should be pretty simple though if you're interested in taking that on as a PR. Dig into |
@jeremydmiller I was looking into doing that last night, but I ran into the issue that if I only handle it in the Since from my quick tests Marten seems to properly handle the custom type mappings that are added to Npgsql (and they are required to work anyway), I am not sure what the value is of keeping the Ideally, I would personally like to have an interface that behind the scenes (also) registers the right mappings in the If I can help anywhere (and can find the time to do so) I would like to. Currently I'm not sure exactly what the "Marten" vision is in this regard. So let me know what your thoughts are :) |
@CptWesley TBH, you're pushing this kind of thing much farther than I was thinking about anyway -- other than a notion that I'd eventually get around to the strong typed identifier support. The I saw some of the Weasel stuff. The PR looks fine, but if you could add some tests just to lock down the behavior, that would be helpful But, just to make this more complicated, I'd also say you need to do something about the JSON serialization for these custom value types. Can you add some context about what your custom value types look like before we do too much more? |
@jeremydmiller For some more context: In production we are using a bunch of (single) value object definitions from this library: https://github.com/Qowaiv/Qowaiv in order to have more strongly typed/meaningful types rather than using primitives everywhere. This includes types such as We recently started moving to Postgres with Marten and in order for the queries to work properly we are now setting/defining the following 3 things:
To simplify things, I have written an abstract
Under the hood this abstract class simply converts the type to the "native" type and then just uses whatever built-in type resolver Npgsql has built-in for that native type. This allows us to create This makes So to me it seems right now that Once I feel a bit better I could write some tests for Marten to ensure that the Npgsql |
@CptWesley Would you mind pasting in your And no, "just" using an |
And this is done now, but do need a blog post or example or something. Not stressing about this too much. Comes in as part of the strong typed identifier work. |
@jeremydmiller sorry for the late reply, I haven't been near a computer for a while. Unfortunately, the code I mentioned earlier is owned by my employer, so I can not share it directly. If it's still useful I might be able to write a different example at some point in the future |
For 7.8.0:
Attempting to perform a query that contains a custom type will (logically) result in the following exception:
However, implementing the
IMemberSource
interface and registering it in theStoreOptions.Linq.MemberSources
does not appear to actually result in theTryResolve
being called. In previous versions we used to implement theIFieldSource
interface and then register them using theStoreOptions.Linq.FieldSources
, which worked fine. However, this interface appears to now have been removed/renamed in favor ofIMemberSource
. When inspecting the source code is seems that theTryResolve
method and the.MemberSources
have 0 references.The text was updated successfully, but these errors were encountered: