0

使用轨道 2.2

你好

当我更新呼叫时,我遇到了一个问题,我的日期被设置为 Time.now。这是因为 Update 语句只传递时间,而不是日期时间。

你可以看到下面

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

传递的时间不是随机的,而是应该传递的日期时间的时间部分。

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]

如您所见,我尝试在更新中设置 Issuelogged_Date,尽管 - 发生了同样的事情 - 它只是通过时间,而不是日期时间。

我真的很纠结该怎么做!任何帮助,将不胜感激!

4

1 回答 1

1

我们发现这取决于 Sybase,即我们使用的任何适配器 gem。

我们修改了第 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 回答