AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

Exception thrown for valid null situation #518

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have a foreign key that can be null.
2. Attempt to retrieve records with a null in that field as follows:
      .BYFieldName(null, ComparisonOperator.Equals)
3.

What is the expected output? Record(s) returned

What do you see instead?
Parameter 'fkParentEvent' cannot be null with the specified ComparisonOperator. 
 Parameter 'comparisonOperator' must be ComparisonOperator.Equals or 
ComparisonOperator.NotEquals to support null.
Parameter name: fkParentEvent 

stack trace shows generated code like so:
if (fkParentEvent == null && (comparisonOperator != ComparisonOperator.Equals 
|| comparisonOperator != ComparisonOperator.NotEquals))
Line 205:                throw new ArgumentNullException("fkParentEvent", 
"Parameter 'fkParentEvent' cannot be null with the specified 
ComparisonOperator.  Parameter 'comparisonOperator' must be 
ComparisonOperator.Equals or ComparisonOperator.NotEquals to support null.");

The || should be && as the two tests will always return true if the || is used.

What version of the product are you using? Codesmith Professional 5.2.0 Rev 
10352
Plinqo version r-1167 as far as I can tell

Please provide any additional information below.

Original issue reported on code.google.com by rogertin...@tfccom.org on 18 Oct 2010 at 11:15

GoogleCodeExporter commented 9 years ago
Hello,

Can you please try reproducing this in the following version of PLINQO 
(http://code.google.com/p/codesmith/downloads/detail?name=PLINQO-v5.0.1.1966.zip
). It should be a hassle free update. The only thing you might have to worry 
about is placing the NotNull attribute on string data typed generated 
properties in the meta data class.

Thanks

-Blake Niemyjski

Original comment by bniemyjski on 18 Oct 2010 at 6:52