0

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

  • [Issuereported_date] = '11:36:00'
  • [Issuelogged_Date] = '11:36:56'

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!

4

1 に答える 1

1

これは、私たちが使用していた Adaptor gem のどこにでもあるSybaseによるものであることがわかりました。

232行目を修正して、時刻がデータベースに正しく渡されるように (または希望どおりに) しました。

変更点:

when Time then "'#{value.strftime("%H:%M:%S")}'"

次のようになります。

when Time then "'#{value.strftime("%Y-%m-%d %H:%M:%S")}'"
于 2012-03-30T12:31:55.267 に答える