The Adapter is unable to handle the 'sysdate' value for date columns.
The following Test produces an error:
def test_syntax_problem_with_sysdate
ActiveRecord::Base.connection.execute "CREATE TABLE TEST_TABLE (VALUE INTEGER, DATUM DATE DEFAULT SYSDATE)"
ActiveRecord::Base.connection.execute "INSERT INTO TEST_TABLE (VALUE) VALUES (1)"
klass = Class.new(ActiveRecord::Base)
klass.set_table_name "TEST_TABLE"
obj = klass.find :first
assert_equal 1, obj.value
assert_not_nil obj.datum
end
ActiveRecord::ActiveRecordError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.hour
test/unit/oracle_konnector_test.rb:29:in `test_syntax_problem_with_sysdate'
/Applications/RubyMine 1.1.app/rb/testing/patch/test/unit/ui/testrunnermediator.rb:36:in `run_suite'
/Applications/RubyMine 1.1.app/rb/testing/patch/test/unit/ui/teamcity/testrunner.rb:69:in `start_mediator'
/Applications/RubyMine 1.1.app/rb/testing/patch/test/unit/ui/teamcity/testrunner.rb:57:in `start'
If you use 'Default sysdate' for a date column, the database will insert the actual timestamp
in the column, if it is null. So you can't use a value in the Application-Tier. The column must
be nil. (N.B.: sysdate is a sql-function which evaluates to the actual timestamp.)
A patch would be to change the method 'default_value' to:
def default_value(value)
return nil unless value
- Not sure why we need this for Oracle?
value = value.strip
return nil if value == "null"
return nil if value == 'SYSDATE'
- jdbc returns column default strings with actual single quotes around the value.
return $1 if value =~ /^'(.*)'$/
value
end
I did not disable the Wiki-Syntax for the new method!
Look into the source of the Page. The Ordernumbers
should be Comment-Signs.