Skip to content
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

IsNew always return false when PrimaryKey is typeof string and value is "" #538

Closed
ArgoZhang opened this issue May 24, 2019 · 4 comments
Closed

Comments

@ArgoZhang
Copy link
Contributor

hi, I found that IsNew function always return false when the poco's PrimaryKey is System.String type and value is "".
in line 2532 will return. so line 2535 will be never work.

if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) || !type.IsValueType)
    return pk == null;

if (type == typeof(string))
    return string.IsNullOrEmpty((string) pk);

it will work fine when the poco PrimaryId value is null.
is it by design? or a bug?

@ArgoZhang
Copy link
Contributor Author

how about this? any question?

@ArgoZhang
Copy link
Contributor Author

still busy? really hope resolve IsNew and Mapper.Register issues. So many string type Primary key in my project. i do not want to create a new class inherit Database and override IsNew function. any question please let me known. thanks

pleb pushed a commit that referenced this issue Aug 2, 2019
* refactor(IsNew): check string type PrimaryKey first #538

#Issue
link #538

* doc: change file endings
@pleb
Copy link
Member

pleb commented Aug 2, 2019

@ArgoZhang, this is now in dev. Use the latest beta nuget package to try it out

@ArgoZhang
Copy link
Contributor Author

@pleb I've tested it. It's working very well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants