-
Notifications
You must be signed in to change notification settings - Fork 124
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
Bug: null reference during fetch #748
Comments
where can i download a DLL to test? https://ci.appveyor.com/project/mikependon/repodb-pqvj7/builds/37333306/artifacts has nothing |
@kbilsted - we will setup a nightly build soon. For now, if you can build it locally, then that would be great. Thanks @SimonCropp for the PR. |
I have recompiled and now I get a just a puzzleing error. Do note that this code is working in Dapper, so I don't think it is a column name mismatch
at least the error reporting should report the type it is operating on catch (Exception ex) |
@kbilsted - I assumed that the null check introduced earlier eliminates the fields necessary for the constructor. It is good if we can revisit it. Would you be able to share the model you are using? Good if you can also share your schema. |
I am wondering how such a change could not break any existing test? |
Sorry to hear that. We need to investigate if your scenario is really covered. If not, we will guard it as always as we found the issues by writing a new Unit or Integration tests. I assumed, your issue is related to immutability which was recently been supported at v1.12.x. Maybe, our test coverage is doesn't covered much as we expected. |
no it is straight forward POCO with string, int, enums and a 1-* relation. On the tables there are triggers perhaps you are parsing the DB schema on startup with the |
How about reporting more type information in the error messages so that we can narrow down the problem? |
Can you revisits whether ever argument in your POCO's constructor is corresponding to the fields returned by your query? |
Hi well I'm not sure what type is the problem. You are not reporting the type in the error message '-) . I have a candidate that has 3 ctor one with 0 arg and two that do not match the SQL query. The class only holds public properties. Perhaps dapper is always choosing the zero arg ctor since it works fine there |
The logic that has been embedded in RepoDB since the start of support to the Immutable Classes is to get the most-argument(ed) ctor and process the resultset of the If any of the ctor argument is not present on the resultset's fields, then an exception will be thrown. |
Ok changing the code, rewriting the constructors to factory methods resolved the issue 2 suggestions
|
That's a good suggestion. I will try to see how to optimize the mapping of the ctor, probably inspecting the properties, or even pass the default values to the non-matched ctor argument (null for nullables). |
We will tag this as working as expected, but we will improve the logic here. We will soon create a dedicated story for this. |
It only works as expected with the PR from @SimonCropp , right ? :-) |
Yeah, you are correct. Btw, do you still encountered the problem on the latest version given with your refactoring on your model? I thought you optimize the way you did the ctor(s)? |
I have not properly checked, since my test suite continued a bit further but only to fail on another problem that I just reported. |
Thanks. Please do let us know if you encountered it on the latest version. In anyway, the fix of @SimonCropp will still be a part of the next release, so either verify wait for it or just verify it there (and revert if it is not a problem there). |
Closing this one as I had created a separate ticket for the enhancement, and beside, the issue is fixed on the next version. |
Bug Description
When fetching I get the exception
I cannot reproduce in a small demo application. I need a few hints on what field e.g. it is failing on.
Exception Message:
Schema and Model:
Please share to us the schema of the table (not actual) that could help us replicate the issue if necessary.
And also the model that corresponds the schema.
Library Version:
Example: RepoDb v1.12.6 and RepoDb.SqlServer v1.1.2
The text was updated successfully, but these errors were encountered: