Assert.tableEquals skip camparing dattime column

Apr 23, 2009 at 8:32 PM
Is there a way to to allow the Assert.tableEquals to ignore datetime columns since the expected and actual datatime stamps will never match?
Apr 29, 2009 at 5:29 PM


Sorry for the delay in answering.

I assume that your scenario is about validating a table returned by a stored procedure. Can you please confirm?

In that case, when you populate the table that contains the actual result you write something like: “INSERT INTO #ActualResult EXEC SomeSproc”. I don’t know of any simple way one can exclude some of the columns from the dataset returned by the sproc.

Of course, you could use a temporary/variable table and from that one transfer only the needed columns into the #ActualResult. However this is too cumbersome. I plan to add an extra parameter to Assert.TableEquals. This parameter will indicate a list of columns that have to be ignored. Let me know of any comments you may have and I’ll figure out a deadline.

Note: If the scenario is to validate a table returned by a function or from a view there is a simple workaround: When creating and populating the table with the actual result just exclude the dattime column you want to ignore. Instead of “INSERT INTO #ActualResult SELECT * FROM dbo.QFn_SomeFunction()” write something like “INSERT INTO #ActualResult SELECT Col1, Col2, Col3 FROM dbo.QFn_SomeFunction()”

Note: In some cases, sprocs can be rewritten as functions. I feel that when possible functions are preferable to sprocs. If you can rewrite your sproc in your case you could do that as a workaround.

May 15, 2009 at 4:02 PM

Another workaround : after the insert into #actualResult , to update the columns to a known value before calling the TST.Assert.TableEquals.

May 18, 2009 at 8:04 PM

The issue is fixed in V1.2.
Assert.TableEquals has a new optional parameter: @IgnoredColumns. You can specify a list of columns that have to be ignored. Example:
EXEC TST.Assert.TableEquals
@ContextMessage = '...',
@IgnoredColumns = 'Create Date;Modified Date'