Reputation: 356
Using RAILS 2.2
Hello
I am having an issue where my dates are being set to Time.now when I update a call. This is because the Update statement is only passing the time, not the datetime.
You can see bellow
The time that is being passed isn't random, it is the time part of the datetime which should have been passed.
Processing IssuesController#update_general (for localhost at 2012-03-02 11:38:53) [POST]
Session ID: BAh7CzoPYZWR7ADoOY2xpcjo6Rmxhc2g6OkZsYXNo%0ASGFzaHsABjoKQHVzZWR7ADoOY2xpZW50X2lkaQY6D0ASGFzaHsABjoKQHVzZWG9yIFdpbGxpYW1z--29udGFjdF9pZGHVz
Parameters: {"commit"=>"Save", "action"=>"update_general", "id"=>"0004", "controller"=>"call/issues", "issue"=>{"ResolutionID"=>"", "EstFixDate"=>"", "ResolutionVersion"=>"", "SeverityID"=>"3", "ResolutionNotes"=>"", "StatusID"=>"1", "Issuelogged_Date"=>"2012-02-12 11:36:56", "CallTypeID"=>"1", "IssueBody"=>"sdg", "Emailsent"=>"1", "IssueHeader"=>"td", "UserID"=>""}}
[4;35;1mSQL (0.000000)[0m [0mSELECT c.COLUMN_NAME as ColName, c.[DEFAULT] as DefaultValue, d.DOMAIN_NAME as ColType, c.WIDTH as Length FROM SYS.SYSCOLUMN c key join (sys.systable t,sys.sysdomain d) WHERE t.TABLE_NAME = 'Contact' ORDER BY column_id[0m
[4;36;1mContact Load (0.000000)[0m [0;1mSELECT TOP 1 * FROM Contact WHERE (Contact.[ContactID] = 12311) [0m
[4;35;1mSQL (0.000000)[0m [0mSELECT c.COLUMN_NAME as ColName, c.[DEFAULT] as DefaultValue, d.DOMAIN_NAME as ColType, c.WIDTH as Length FROM SYS.SYSCOLUMN c key join (sys.systable t,sys.sysdomain d) WHERE t.TABLE_NAME = 'CALL_Issue' ORDER BY column_id[0m
[4;36;1mCall::Issue Load (0.000000)[0m [0;1mSELECT * FROM CALL_Issue WHERE (CALL_Issue.[IssueID] = '0004') [0m
[4;35;1mSQL (0.000000)[0m [0mSELECT @@ROWCOUNT AS AffectedRows[0m
[4;36;1mCall::Issue Update (0.015000)[0m [0;1mUPDATE CALL_Issue SET [IssueBody] = 'sdg', [LastEdited_By] = 12311, [Issuereported_date] = '11:36:00', [PlatformID] = NULL, [ApplicationID] = 387, [SLAMet] = 0, [HandHeldID] = NULL, [StatusID] = 1, [ResolutionNotes] = '', [SeverityID] = 3, [Comments] = NULL, [Emailsent] = 1, [ModuleID] = NULL, [Issuelogged_Date] = '11:36:56', [BeginProjectWork] = 0, [ResolutionVersion] = NULL, [EstFixDate] = NULL, [ClientUserID] = 12311, [ClientID] = 1, [IssueHeader] = 'td', [UserID] = NULL, [ClientComments] = NULL, [Issuelogged_by] = 12311, [CallTypeID] = 1, [priority] = 3, [IssueClientRef] = NULL, [ResolutionID] = NULL, [ClientSpecific] = 0, [IntComments] = NULL WHERE [IssueID] = 0004[0m
Redirected to http://localhost:3000/call/issues/0004
Completed in 0.10900 (9 reqs/sec) | DB: 0.01500 (13%) | 302 Found [http://localhost:3000/call/issues/update_general/0004]
As you can see, I've tried setting the Issuelogged_Date in my update, although - same thing happens - it just passes the time, and not the datetime.
I'm really stuck on what to do! Any help would be appreciated!
Upvotes: 0
Views: 242
Reputation: 356
We found that this was down to the Sybase, anywhere Adapter gem we were using.
We modified line 232 so Time was correctly (or how we wanted it to be) passed to the database.
Changes:
when Time then "'#{value.strftime("%H:%M:%S")}'"
now looks like:
when Time then "'#{value.strftime("%Y-%m-%d %H:%M:%S")}'"
Upvotes: 1