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

Insert with Guid as Key: Inconsistent behaviour async/sync #253

Open
amagno-jco opened this issue Oct 12, 2021 · 0 comments
Open

Insert with Guid as Key: Inconsistent behaviour async/sync #253

amagno-jco opened this issue Oct 12, 2021 · 0 comments

Comments

@amagno-jco
Copy link

When executing an Insert with a Guid as a key, a select statement is appended to the query:
sb.Append(";select '" + idProps.First().GetValue(entityToInsert, null) + "' as id"); (https://github.com/ericdc1/Dapper.SimpleCRUD/blob/master/Dapper.SimpleCRUD/SimpleCRUD.cs#L403). The corresponding line is missing in the async code (https://github.com/ericdc1/Dapper.SimpleCRUD/blob/master/Dapper.SimpleCRUD/SimpleCRUDAsync.cs#L282).

I guess the select statement is (or was) used to get the return value, but it's not needed (as we can see with the async version). This can lead to problems because the query stops being completely parametrized:
insert into [FooTable] ([Id], [BarValue]) values (@Id, @BarValue);select 'some-explicit-guid' as id

I suggest to completely remove the select statement. Should I create a PR?

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

1 participant