# MySql column names with "-" in them

**URL:** <https://www.ruby-forum.com/t/mysql-column-names-with-in-them/138971>\
**Category:** Rails\
**Created:** [May 29, 2008, 4:51pm UTC](https://www.ruby-forum.com/t/mysql-column-names-with-in-them/138971 "2008-05-29T16:51:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/8dc957/32.png) [@ethan](https://www.ruby-forum.com/u/ethan)\
**Post date:** [May 29, 2008, 4:51pm UTC](https://www.ruby-forum.com/t/mysql-column-names-with-in-them/138971/1 "2008-05-29T16:51:16Z")

</div>

I am getting warnings in my logs for updates to a table I created that  
has column names from an XML response file i get from Google Checkout  
notifications. I basically log the orders into a mimicked table.  
Column names examples are “total-refund-amount” and so on.

Below are the warnings. Any ideas on how to supress this? my updates  
are working. But its a pain to scroll through logs when one order  
creates about 300kb of text regarding these warnings.

Has anybody experienced this? found a work-around?

Exception occurred during reader method compilation.  
Maybe total-refund-amount is not a valid Ruby identifier?  
compile error  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/  
attribute\_methods.rb:160: syntax error, unexpected ‘-’, expecting ‘\n’  
or ‘;’  
def total-refund-amount; missing\_attribute(‘total-refund-amount’,  
caller) unless @attributes.has\_key?(‘total-refund-amount’);  
(v=@attributes[‘total-refund-amount’]) &&  
ActiveRecord::ConnectionAdapters::MysqlColumn.value\_to\_decimal(v); end  
^  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/  
attribute\_methods.rb:160: syntax error, unexpected kEND, expecting  
$end  
def total-refund-amount; missing\_attribute(‘total-refund-amount’,  
caller) unless @attributes.has\_key?(‘total-refund-amount’);  
(v=@attributes[‘total-refund-amount’]) &&  
ActiveRecord::ConnectionAdapters::MysqlColumn.value\_to\_decimal(v); end  
^  
Exception occurred during reader method compilation.  
Maybe total-refund-amount is not a valid Ruby identifier?  
compile error  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/  
attribute\_methods.rb:160: syntax error, unexpected ‘-’, expecting ‘\n’  
or ‘;’  
def total-refund-amount=(new\_value);write\_attribute(‘total-refund-  
amount’, new\_value);end  
^  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/  
attribute\_methods.rb:160: syntax error, unexpected kEND, expecting  
$end  
def total-refund-amount=(new\_value);write\_attribute(‘total-refund-  
amount’, new\_value);end  
^  
Exception occurred during reader method compilation.  
Maybe total-refund-amount is not a valid Ruby identifier?  
compile error  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/  
attribute\_methods.rb:160: syntax error, unexpected ‘-’, expecting ‘\n’  
or ‘;’  
def total-refund-amount?; query\_attribute(‘total-refund-amount’); end  
^  
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/  
attribute\_methods.rb:160: syntax error, unexpected kEND, expecting  
$end  
def total-refund-amount?; query\_attribute(‘total-refund-amount’); end  
^

thanks, Ethan

---

<div class="post-metadata">

**Author:** ![ethan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/8dc957/32.png) [@ethan](https://www.ruby-forum.com/u/ethan)\
**Post date:** [May 29, 2008, 4:53pm UTC](https://www.ruby-forum.com/t/mysql-column-names-with-in-them/138971/2 "2008-05-29T16:53:37Z")

</div>

The easiest solution would be to rename your fields with undescores to  
follow Rails conventions.

If you need to stuff map easily, a substitution on ‘-’ for ‘\_’ is easy  
enough to handle in your processing code.

Robby

On Thu, May 29, 2008 at 7:50 AM, Ethan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Has anybody experienced this? found a work-around?  
> caller) unless @attributes.has\_key?(‘total-refund-amount’);  
> ^  
> attribute\_methods.rb:160: syntax error, unexpected kEND, expecting  
> def total-refund-amount?; query\_attribute(‘total-refund-amount’); end

–  
Robby R.  
Founder and Executive Director

PLANET ARGON, LLC  
Design, Development, and Hosting with Ruby on Rails

> **[Planet Argon](https://www.planetargon.com/)**
>
> Planet Argon is a Ruby on Rails development agency specializing in maintenance and support for existing Rails apps. Based in Portland, OR, Planet Argon has been a member of the Rails community since 2004.

[http://www.robbyonrails.com/](http://www.robbyonrails.com/)  
aim: planetargon

+1 503 445 2457  
+1 877 55 ARGON [toll free]  
+1 815 642 4068 [fax]
