Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Prevent creation of database columns with a reserved name #2629

marceldegraaf opened this Issue · 10 comments

5 participants


Today I ran into this issue: apparently a database column with the name hash breaks things, resulting in a non-helpful error:

TypeError (can't convert String into Integer)

Creation of columns with reserved names should be prevented. If that is impossible, a more helpful error message would be awesome.


Any other words except hash?


Not that I'm aware of, but I have no idea how to find out. All the reserved words lists I could find online seem to be hopelessly outdated.

This page has a comprehensive list, but it is from 2007:

There are two wiki entries that seem to deal with reserved words, but one is empty and the other only contains a dead link: (has dead link) (is empty)

I could find no mention of reserved column names in the Rails Guides as well.


@marceldegraaf Is this still an issue?


@marceldegraaf hey, can you provide a patch for this? That'd be awesome, and if you need any help, just let us know. Thanks!


Oh yah! I am just helping triage things for the Rails core team. Thanks!


@marceldegraaf sounds good, I'll leave the issue open for now and will revisit in a couple weeks. Thanks.


Just more info: I just tested with Rails 3 and was able to run the generator and migrate the database, but not instantiate / create a record:

>> HashTest.create! :name => 'fuu', :hash => 'yeah!'
ActiveRecord::DangerousAttributeError: hash is defined by ActiveRecord
    from .../gems/activerecord-3.2.3/lib/active_record/attribute_methods.rb:90:in `instance_method_already_implemented?'

Hash method is reimplemented in AR


I'm closing this as stale. Please, use the Ruby on Rails Core mailing list to ask for feedback about new features or changes in Rails, or try to create a pull request so people can review the feature with real code. You can also use the Ruby on Rails Talk mailing list for general questions and doubts about the framework. Thanks.


I named a column "length" (quite common) and created me a lot of troubles... I had to rename it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.