quaiton89 / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

Dapper.Contrib.Extensions - conn.Delete<MyType>(null) deletes everything on postgresql #90

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Delete<MyType>(null);

This generates the following SQL (using the attached file):
delete from adavetest2 where ADaveTestId = @ADaveTestId

The parameter is not populated as null is passed. In postgresql "@" is the 
unary absolute operator, so this query deletes everything with id >= 0.

What is the expected output? What do you see instead?
An error of some sort.

There are two ways we could solve this:

Have .Delete<>() throw an exception when passed null. (This sounds like a good 
way to me)

Or change the parameters to use : instead of @, this will then generate an 
error at the database server end as : is not a valid operator.

I'll do a github pull request with the first fix momentarily.

Original issue reported on code.google.com by elite.da...@gmail.com on 22 Mar 2012 at 10:41

Attachments: