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

Bug in ActiveRecord.tt file #35

Open
yjagota opened this issue Oct 26, 2009 · 1 comment
Open

Bug in ActiveRecord.tt file #35

yjagota opened this issue Oct 26, 2009 · 1 comment

Comments

@yjagota
Copy link

yjagota commented Oct 26, 2009

At Line 273 of ActiveRecord.tt, Equals method performes the equality using this line:
return compare.KeyValue()==this.KeyValue();
where it should be:
return compare.<#=tbl.PK.CleanName#>==this.<#=tbl.PK.CleanName#>;

KeyValue() returns an object. Consider the case where Primary key is an int. When a boxed int is returned from KeyValue method, Equals method will return false in every case (even if the primary int key contains the same value) because the == operator checks for referential equality as object is a class (int is a type) and both the objects are sitting at different memory locations in the heap.

The reason I am posting this is because this caused a very irritating error in my WPF ListView. Details here:
http://stackoverflow.com/questions/1621239/wpf-listview-gridview-single-selection-bug

@epalm
Copy link

epalm commented Nov 12, 2010

This was driving me crazy, I thought something was wrong with my XAML. My ListBox just wouldn't work properly. I finally tracked it down to Equals doing weird things. Thanks for the validation, yjagota.

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