Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concatenation changes default value in model #6115

Closed
alexeyramazanov opened this issue May 2, 2012 · 1 comment
Closed

Concatenation changes default value in model #6115

alexeyramazanov opened this issue May 2, 2012 · 1 comment

Comments

@alexeyramazanov
Copy link

Rails 3.2.3 Ruby 1.9.3.125
Example shows the problem:

create_table "settings" do |t|
  t.string   "param", :null => false
  t.text     "value", :null => false
  t.datetime "created_at"
  t.datetime "updated_at"
end

> Setting.column_defaults
 => {"id"=>nil, "param"=>nil, "value"=>"", "created_at"=>nil, "updated_at"=>nil}
> Setting.new    
 => #<Setting id: nil, param: nil, value: "", created_at: nil, updated_at: nil> 
> s = Setting.new
 => #<Setting id: nil, param: nil, value: "", created_at: nil, updated_at: nil> 
> s.value << "text" # MAGIC STARTS HERE
 => "text" 
> s
 => #<Setting id: nil, param: nil, value: "text", created_at: nil, updated_at: nil> 
> Setting.new
 => #<Setting id: nil, param: nil, value: "text", created_at: nil, updated_at: nil>
> Setting.column_defaults
 => {"id"=>nil, "param"=>nil, "value"=>"text", "created_at"=>nil, "updated_at"=>nil} 
@pixeltrix
Copy link
Contributor

@tenderlove @jonleighton should we freeze the hash?

drogus added a commit to drogus/rails that referenced this issue May 4, 2012
@drogus drogus closed this as completed in c517602 May 5, 2012
yahonda added a commit to yahonda/rails that referenced this issue Jul 24, 2012
…#6115 issue tested.

Issue rails#6115 has been fixed and tested with
the attribute `:null => false, :default => ""`
However `:null => false` attribute is not necessary to test this issue,
which causes many ORA-01400 errors with Oracle enhanced adapter.
rafaelfranca added a commit that referenced this issue Jul 24, 2012
Addresses ORA-01400 errors and also supports #6115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants