-
Notifications
You must be signed in to change notification settings - Fork 622
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
CASSGO-36 could map scan get nil instead of zero value for null value #1834
base: trunk
Are you sure you want to change the base?
Conversation
Based on this being possible outside of the package I'm hesitant to approve this. See my comment on the original issue: #1699 (comment) |
@jameshartig I believe we should consider implementing features directly within gocql rather than requiring external solutions. It would be much more convenient to have these features available out of the box. Furthermore, it seems like this behavior should be the default since Cassandra can return nullable values. Currently, gocql represents these as default Go values, which alters the original data. To address this, we should at least provide an alternative functionality that preserves the original data and aligns with Cassandra's behavior. |
So it looks like @jameshartig is proposing a change to the behavior of |
Or is #1856 just limited to byte slices and we still can't read nullable values for other types? |
Yes, that's just for byte slices. The reason being that nil slices are equivalent to empty slices and there's no need to make an empty slice if we don't need to.
This is maybe something we can consider for 2.0 but there's no way we could make that change in the existing version.
You can use pointers if you which to get the "original data". I've seen places that utilize the default Go values as a feature because they don't have to check for nil and can rely on the default value. I also provided a code example in the original issue with how you can do this quite easily without any changes to gocql. |
The release that we're working on atm ( |
So it looks like there's no consensus on whether CASSGO-36 should actually be considered, maybe this needs a [discuss] thread on the C* dev mailing list? |
It seems like misbehavior that MapScan doesn't get the original data from the database. Sure, we can use Scan and make a custom "MapScan" as suggested in #1699 (comment), but it looks like overhead, and as mentioned in the issue, it's confusing, but it is still confusing, especially for new users, and imo MapScan doc is not clear enough when we're talking about null values. I think there is no issue with backward compatibility because this functionality will be added to 2.0. |
I agree with @joao-r-reis, I think we need more consensus that "original data" is not the default go values and is actually
We can definitely clarify the docs.
You're changing a public interface which means anything implementing
I can appreciate your frustration but we want to decrease the surface area of the API and not increase it. We're stuck with |
I think I misunderstood this issue because reading this comment #1785 (comment) made me believe that we actually have no way of differentiating between a NULL and empty value from the database. It looks like there is indeed a way of doing this even if it requires a bit of extra code, correct? If this is the case then I'm starting to lean with @jameshartig here and CASSGO-36 (+ this PR) should probably just be closed |
Closes #1699
This PR adds a new feature (MapScanWithNullableValues) that allows users to receive nullable values from Cassandra.