jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-2465

2 digit year resolves to 1st century rather than 20th when using postgres timestamp with timezone + activerecord-jdbcpostgresql-adapter

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: JRuby 1.1.1
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    jruby 1.1.1 (and 1.1)
    RoR 2.0.2
    activerecord-jdbcpostgresql-adapter 0.8
    attachment_fu vendor plugin
    jruby-openssql 0.2.2
    windows xp pro
    postgresql 8.2

Description

Hi -

When a user inputs a date using a 2 digit year, jruby (and/or activerecord-jdbcpostgresql-adapter) inserts a 1st century year into the database. For example:

ex) 04/28/08 <-- user input

in the controller:
db_insert = SomeActiveRecordModel.new(:the_date => params[:some_date])
db_insert.save

In the database, it is saved as:
0008-04-28

In native ruby, this same situation resolves to 20th century years - 2008

I've verified this behavior for timestamp with timezone and date data types

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Thomas E Enebo added a comment - 12/May/08 3:07 PM

Perhaps unfairly giving this to Nick, but I think he can find this faster than I can.

Show
Thomas E Enebo added a comment - 12/May/08 3:07 PM Perhaps unfairly giving this to Nick, but I think he can find this faster than I can.
Hide
Permalink
Nick Sieger added a comment - 13/May/08 4:11 PM

Can you write a test against ar-jdbc for this? In a quick attempt, I was unable to reproduce this. A test like this:

diff --git a/test/simple.rb b/test/simple.rb
index 397be7c..dc2458a 100644
--- a/test/simple.rb
+++ b/test/simple.rb
@@ -69,6 +69,12 @@ module SimpleTestMethods
     assert_equal @new_title, post.title
   end
 
+  def test_create_entry_date_with_string
+    post = Entry.new(:title => "blah", :updated_on => "04/28/08")
+    assert post.save
+    assert_equal "2008-04-28", Entry.find(post.id).updated_on.to_date.to_s(:db)
+  end
+
   def test_destroy_entry
     prev_count = Entry.count
     post = Entry.find(:first)

Gives an error like so:

  1) Failure:
test_create_entry_date_with_string(MysqlSimpleTest) [/Users/nicksieger/Projects/jruby/extras/activerecord-jdbc/test/simple.rb:75]:
<"2008-04-28"> expected but was
<"2008-05-13">.
Show
Nick Sieger added a comment - 13/May/08 4:11 PM Can you write a test against ar-jdbc for this? In a quick attempt, I was unable to reproduce this. A test like this:
diff --git a/test/simple.rb b/test/simple.rb
index 397be7c..dc2458a 100644
--- a/test/simple.rb
+++ b/test/simple.rb
@@ -69,6 +69,12 @@ module SimpleTestMethods
     assert_equal @new_title, post.title
   end
 
+  def test_create_entry_date_with_string
+    post = Entry.new(:title => "blah", :updated_on => "04/28/08")
+    assert post.save
+    assert_equal "2008-04-28", Entry.find(post.id).updated_on.to_date.to_s(:db)
+  end
+
   def test_destroy_entry
     prev_count = Entry.count
     post = Entry.find(:first)
Gives an error like so:
  1) Failure:
test_create_entry_date_with_string(MysqlSimpleTest) [/Users/nicksieger/Projects/jruby/extras/activerecord-jdbc/test/simple.rb:75]:
<"2008-04-28"> expected but was
<"2008-05-13">.
Hide
Permalink
Charles Oliver Nutter added a comment - 06/Feb/09 8:50 AM

Nick was unable to reproduce this and there was no followup from the author..

Show
Charles Oliver Nutter added a comment - 06/Feb/09 8:50 AM Nick was unable to reproduce this and there was no followup from the author..

People

  • Assignee:
    Charles Oliver Nutter
    Reporter:
    Jin Lee
Vote (0)
Watch (1)

Dates

  • Created:
    28/Apr/08 4:40 PM
    Updated:
    27/Oct/09 1:48 PM
    Resolved:
    06/Feb/09 8:50 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.