Correct method of saving timestamps

0 views
Skip to first unread message

Joseph Lamoree

unread,
Dec 3, 2009, 1:09:06 PM12/3/09
to Reactor
I have a MSSQL database with a table that has a datetime column, with
a default of getdate(). When the column is nullable, Reactor inserts a
null value (and the resulting value stored is null, not the current
time). When the column does not allow null values, Reactor tries to
insert a zero-character string causing an SQL error. I believe this is
true even with the version of Reactor pulled from Subversion recently.

So, what is the correct way to have a timestamp column in the database
be invisible to Reactor? I just want the database to do its thing
without interference.

As a workaround, I've been setting the timestamp property in the
Reactor record to CFML's now(). But I'd really rather the value be
based on the database server's clock.

Thank you.

-joseph

Chuck Savage

unread,
Dec 3, 2009, 8:00:51 PM12/3/09
to reacto...@googlegroups.com
Well I'm brand new to Reactor, but I can answer half the question from a database standpoint.  I'd use a View of the table that doesn't have the timestamp column.  I'd bet Reactor doesn't differentiate between Views and Tables, if the View is just a subset of the table.  But this still leaves you with the auto-inserting of the now().  If you know how to program in sql, then you could create a stored procedure for injecting the database server's timestamp in place when the record is created.  I forget what they are called, but you can have procedures invoked when records are created.  Stored procedures are programs that run database side but can be called from <cfquery>, and a good program I use for mysql is Navicat, and they probably have a mssql version as well.  It isn't free, but I like it.


--

You received this message because you are subscribed to the Google Groups "Reactor" group.
To post to this group, send email to reacto...@googlegroups.com.
To unsubscribe from this group, send email to reactor-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/reactor-users?hl=en.





--
Chuck Savage
SeaRisen LLC
Website: http://www.SeaRisen.com

Joseph Lamoree

unread,
Dec 4, 2009, 12:02:54 PM12/4/09
to Reactor
Thanks Chuck.

I suppose what you're suggesting could work. I'm really more
interested in the way that the Reactor developers intended it to work.
This is a very common issue, so I'm sure they've already solved it.

The way that I do this with Transfer ORM is to set XML attributes
within the object definition file to ignore inserts/updates on the
property, regardless of the value within the object. On the database
(PostgreSQL is my pref) I have a simple trigger that sets the column
to the current time upon row creation. It works a treat.

-joseph

Chris Blackwell

unread,
Dec 4, 2009, 5:54:38 PM12/4/09
to reactor-users
Using the latest version of reactor from svn, you can tell reactor to ignore specific fields.
e.g.

<object name="Something">
   <field name="myfield" ignore="true" />
</object>

This should cause reactor to completely ignore that field when updating the database, but also it won't generate get/set methods.

Chris

2009/12/3 Joseph Lamoree <jlam...@gmail.com>

Joseph Lamoree

unread,
Dec 6, 2009, 3:58:57 PM12/6/09
to Reactor
That's perfect; exactly what I was looking for. I'll pull down the
latest. Thanks Chris.

-joseph
Reply all
Reply to author
Forward
0 new messages