﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on Working around SQL Server bugs</title><description>@Bob,
  
Just use "data source=:memory:" in the connection string.
  
Then you need to generate the schema, for that you will need to pass the IDbConnection to the SchemaExport, I added an Execute() method that does that.
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment16</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment16</guid><pubDate>Sat, 02 Jun 2007 13:31:39 GMT</pubDate></item><item><title>Ayende Rahien commented on Working around SQL Server bugs</title><description>No, that is translation from HQL (object based) to SQL (table based)
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment15</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment15</guid><pubDate>Thu, 31 May 2007 21:28:07 GMT</pubDate></item><item><title>Eber Irigoyen commented on Working around SQL Server bugs</title><description>you may have mistyped stuff, but
  
  
your query:
  
from Address
  
  
generated query:
  
from Addresses
  
  
that would be unknown...
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment14</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment14</guid><pubDate>Thu, 31 May 2007 21:22:29 GMT</pubDate></item><item><title>Ayende Rahien commented on Working around SQL Server bugs</title><description>Can you define what you mean?
  
It is correct in that it is valid SQL. It is not correct in that SQL Server fails to run it.
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment13</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment13</guid><pubDate>Thu, 31 May 2007 20:25:31 GMT</pubDate></item><item><title>Eber Irigoyen commented on Working around SQL Server bugs</title><description>isn't the first generated query incorrect though?
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment12</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment12</guid><pubDate>Thu, 31 May 2007 19:47:41 GMT</pubDate></item><item><title>Ayende Rahien commented on Working around SQL Server bugs</title><description>@Mr_Database,
  
TSQL is a highly inefficent language to work with for a lot of scenarios. Building queries happens to be one of those.
  
Being able to construct queries on the fly, based on business conditions and according to my domain is extremely powerful an enable me to do a lot of stuff that is really not trivial to do otherwise.
  
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment11</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment11</guid><pubDate>Wed, 30 May 2007 13:13:17 GMT</pubDate></item><item><title>Tobin Harris commented on Working around SQL Server bugs</title><description>I'm currently testing against SQL2005 db rather than an in-memory db. 
  
  
I'd agree with Ayende that this approach is too costly - the whole tear-down/set up of dropping/creating the db is becoming annoying to the point where I don't want to run all my tests, which is a BAD THING. 
  
  
I reckon migrating my tests to SQLite will be very easy, just need to put 10 mins aside to work out how to install the thing and tweak the config for my testing assembly. 
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment10</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment10</guid><pubDate>Wed, 30 May 2007 12:29:26 GMT</pubDate></item><item><title>Mr_Database commented on Working around SQL Server bugs</title><description>Just write TSQL if that is what the customer is running.  Your stuff will always run and those left behind after you are long gone won't have to learn yet ANOTHER tool just to maintain your code.
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment9</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment9</guid><pubDate>Wed, 30 May 2007 12:16:18 GMT</pubDate></item><item><title>Ayende Rahien commented on Working around SQL Server bugs</title><description>@Jericho,
  
I have integration tests to catch those type of differences, but I have a lot of tests that does various sorts of queries, and trying to do it against remote server would be really expensive.
  
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment8</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment8</guid><pubDate>Wed, 30 May 2007 10:04:13 GMT</pubDate></item><item><title>Ayende Rahien commented on Working around SQL Server bugs</title><description>Costly, 
  
Writing those unit tests (~30) involved many changes to the code, involving many changes to the schema, and evolved very quickly. 
  
Using in memory I just return the tests, using SQL Server from the start, I would have to re-gen the schema from scratch, which takes time.
  
Certainly doable (that is how the NH tests are working, after all) just much more costly.
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment7</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment7</guid><pubDate>Wed, 30 May 2007 04:40:26 GMT</pubDate></item><item><title>Ayende Rahien commented on Working around SQL Server bugs</title><description>Roy,
  
This is literally the first time that I had run into this issue, and the solution has turned out to be moving the location of a join, so I wouldn't consider this a major concession to living on several databases,
  
  
I think that querying is a business concern, and as such, requires testing:
  
http://www.ayende.com/Blog/archive/2007/03/09/Querying-is-a-business-concern.aspx
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment6</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment6</guid><pubDate>Wed, 30 May 2007 04:06:53 GMT</pubDate></item><item><title>Roy Osherove commented on Working around SQL Server bugs</title><description>That's one of the reasons why I don't support the notion of writing "unit tests" against a database, or the idea of mocking or replacing a DB for tests. You end up not testing the real DB, and you just might (like in your case) ed up with a different feature set just so it can live up bth to the "fake" and to the "real" database, a feature that was not needed.
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment5</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment5</guid><pubDate>Wed, 30 May 2007 02:29:02 GMT</pubDate></item><item><title>Ayende Rahien commented on Working around SQL Server bugs</title><description>&gt; Would you mind posting the generated TSQL from your working solution?
  
  
That is three pages worth, I would rather not :-)
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment4</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment4</guid><pubDate>Tue, 29 May 2007 21:20:35 GMT</pubDate></item><item><title>Ayende Rahien commented on Working around SQL Server bugs</title><description>I would probably start by testing without a DB at all, testing just the interaction described above, using mocks.
  
But, if you have NHibernate running than it should be very easy to get it running on an in memory db.
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment3</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment3</guid><pubDate>Tue, 29 May 2007 21:05:14 GMT</pubDate></item><item><title>Luke Breuer commented on Working around SQL Server bugs</title><description>Don't you prefer to perform all joins with join clauses using the "on" keyword?  Or is this not an option with NHibernate?  Would you mind posting the generated TSQL from your working solution?  I should think the where clause would cancel out the effect of the "left" in the join, but I'm not sure of the rules for odd constructs like you've posted.
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment2</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment2</guid><pubDate>Tue, 29 May 2007 21:03:36 GMT</pubDate></item><item><title>Marvin commented on Working around SQL Server bugs</title><description>It's good that you bring this up.
  
  
Unfortunately I can't use an in-memory DB for unit tests at this time because we have old software that is wired to a crappy SQLBase database.
  
We would like to migrate to SQL Server, which is one reason why we need more unit tests.
  
  
One algorithm I'd like to test goes like this (it's actually something else, but you'll get the idea):
  
  
A customer has a birthday (DateTime) and an age (int).
  
We want to update the customer's age.
  
So the algorithm goes like this:
  
  
- Load a given customer.
  
- If he doesn't have a birthday, send a message to the boss (create an entry in the MESSAGES table), telling him that an employee has forgotten to ask the customer for his birthday ;-). Abort the operation.
  
- Calculate the new age.
  
- If the new age differs from the old age, send a message to the developer (again, an entry in the MESSAGES table), telling him his code is crap ;-).
  
- Finally, if his birthday was within last week, send him a gift, based upon his last order (evaluate last order, create new order).
  
  
As you can see, there are quite a lot of tables involved.
  
At least:
  
  
CUSTOMERS
  
EMPLOYEES
  
MESSAGES
  
ORDERS
  
PRODUCTS
  
ADDRESSES
  
  
Futhermore, there are lots of methods involved (if StoreCustomer() fails, the whole operation will fail), which all will have to be tested.
  
How do you do that?
  
  
I could of course use an empty database and insert all objects I will need (including his last order) and delete everything again once I'm done.
  
But as there are many columns etc., I'd prefer a different approach.
  
  
Like configuring the database using the GUI of our application and then using that database for all unit tests, restoring it after each test.
  
But how can you tell the unit test which customer to use in an elegant way? I can configure the customer ID in the application settings, but I still don't think that's the best approach.
  
  
And (the actual reason why we've decided to add MANY more unit tests):
  
  
We recently discovered a horrible bug in NullSafeGet in one of our custom NHibernate datatypes. NullSafeSet on the other hand worked correctly, so data was destroyed.
  
  
I then wrote a unit test that loaded, stored and loaded data and compared the values. But even then you can never be sure you've screwed something up (columns in the wrong order in the mapping file etc.).
  
How would you write a unit test for such a case?
</description><link>http://ayende.com/2457/working-around-sql-server-bugs#comment1</link><guid>http://ayende.com/2457/working-around-sql-server-bugs#comment1</guid><pubDate>Tue, 29 May 2007 20:51:52 GMT</pubDate></item></channel></rss>