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

Feature request [ready to pull]: Accurately auto-setting CreatedOn and ModifiedOn values #34

Open
TheDistantSea opened this issue Oct 6, 2009 · 0 comments

Comments

@TheDistantSea
Copy link
Contributor

SS provides special treatment for "CreatedOn" and "ModifiedOn" columns when it finds them in a database table. This treatment includes setting them to DateTime.Now whenever a record is created or updated respectively.

The problem stemming from this is that when these values are stored in DATETIME columns they get truncated down to whole seconds. This makes the objects which had their value auto-set differ from the logically identical objects you get from querying the database (these last ones have truncated, and hence different, DATETIME values).

Example: Class Foo models a table in the database that has a CreatedOn column and you do:

var foo1 = new Foo() { Name = "UniqueFoo" };
foo1.Save();
var foo2 = Foo.SingleOrDefault(foo => foo.Name == "UniqueFoo");
if (foo1.CreatedOn != foo2.CreatedOn) {
    Console.WriteLine("Surprise!");
}

This will print out "Surprise!" with near certainty.

While this inconsistency could be considered as "why do you even bother"-level minor, it does prevent me from writing correct unit tests for projects which use SubSonic to talk to the db. Please consider pulling in this patch that fixes the issue:

http://github.com/defacer/SubSonic-3.0-Templates/commit/71f06697bfc41e96d1661d8e3a6d6e063fd99864

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

1 participant