Posts tagged sql

There are 2 posts for the tag sql

Almost equal

Had another interesting problem today. A test that really should have worked started failing most of the time. The test was designed to make sure that a certain DateTime value did not change on update under a special circumstance. It was designed something like this: [TestMethod] public void Updating_Foo_Will_Not_Update_ChangeDate() { //Create a Foo to work with Foo foo = new Foo() { Name = "Update test foo", }; foo = repository.SaveFoo( foo ); DateTime lastChan...

Posted by johan on October 27, 2009

In SQL, null is not != 1

Had an interesting error today. An database query that should have returned thousands of lines returned nothing. Turned out it was due to how the inequality operator works in SQL. In most programming languages, like C# or java the inequality operator handles null, so for example the following code (although extremely stupid) will work. bool? nullValue = null; bool? trueValue = true; bool? falseValue = false; Console.WriteLine((true != nullValue) ); Console.WriteLine((true != trueValue) ); Conso...

Posted by johan on October 15, 2009