-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
splitOn can't handle NULL value #266
Comments
I tried to clean up the issue...but I'm still not sure exactly what's happening here. Can you include a full example? I'm not sure if the splitOn is keyed on a null return but I can likely take a look next week - a full example would be easier to repro so we're on the same page and I can fix it accordingly. |
Hi Nick, |
I believe the issue is described in more detail here, and appear not to be resolved at the moment: http://stackoverflow.com/questions/10744728/dapper-multimap-doesnt-work-with-spliton-with-null-value An allowSplitOnNull: true setting would be usable here, that would inspect all columns for values and not just the splitOn column. This is for scenarios where you have an object composed of several others, some of which are value objects without a meaningful id of their own. |
@wezzix thanks for adding context here - we'll take a look at scanning all columns so no new options are even necessary. |
I opened a similar issue ( We use the pattern below quite a bit (because our PK's are not 'Id'). (p = products table, c = optional categories table)p.*, c.CategoryID AS Id, c.*On Fri, Mar 25, 2016 at 2:19 PM, Nick Craver notifications@github.com
|
In your use case with LEFT JOIN I can fully understand that this is not an issue. |
Wezzix, We don't split on trivial value objects such as a 'DateRange' I'll grant you that it's slightly quirky. But it's totally transparent, So the general rule of thumb for us is: split on tables (e.g. Employees), On Tue, Mar 29, 2016 at 8:38 AM, wezzix notifications@github.com wrote:
|
Hi, I'm using dapper 1.50.2 but the problem still appears. Is there already a better fix available than adding a surrogate column? |
The problem is still present under Dapper 1.50.5 (I tried under SQL Server 2017, if that matters). Adding a dedicated non-NULL split column such as... SELECT
-- first object columns
0 SPLIT,
-- second object columns
FROM
... ...solves it, but this behavior is unexpected and it took me quite a while to figure out the problem (under a ton of other code). I don't think the current behavior should be the default. |
i still have the same problem in 1.50.5 |
Any update on this? Is this going to be fixed in the near future release? The OP started this thread in 2015. |
Still an issue, specifically for splitting keyless data returned from a stored procedure into multiple objects. If the splitOn column is null, the object won't get mapped at all even if other fields in the object have values. |
Hi,
I noticed splitOn can't handle NULL value. for example: if I use sth like
select c.*, c1.* from ...
, whenxxx_id
is the first column of tablec1
and its value is null, dapper will fail to convert it into the mapping type, instead return a null.My work around is manual inserting a id field like
select c.*, 1 as id, c1.* from ....
and dapper works well.
The text was updated successfully, but these errors were encountered: