[ActiveRecord] new connector implementation gives 'unknown attribute error'


#1

Hi all,
I’m implementing an activerecord connector on top of a database driver
I wrote (in pure ruby).

The platform of reference is a Mac OSX 10.5 box with the shipped ruby
interpreter version 1.8.6 and activerecord 2.3.2.

Table creation and select queries work; I though have some problems
when I try to perform insertion.

As an example I created a table called ‘albums’:

ActiveRecord::Schema.define do
create_table :albums do |table|
table.column :title, :string
table.column :performer, :string
end
end

class Album < ActiveRecord::Base
end

Manual insertion works:
sql>insert into albums (title, performer) values (‘a’, ‘b’);

±—±-------±-------------+
| id | title | performer |
+==+====+=======+
| 1 | a | b |
±—±------±--------------+

Selection seems to be working:

puts Album.find(:first)[‘title’]

returns:

“a”

When I try to call the create method though I get an AttributeError:

album = Album.create(:title => ‘Black and Blue’, :performer => ‘The
Rolling Stones’)

/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/
base.rb:2745:in `attributes=’: unknown attribute: title
(ActiveRecord::UnknownAttributeError)

When enabling Logger I get the following:

Exception occurred during reader method compilation.
Maybe “performer” is not a valid Ruby identifier?
compile error
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/
attribute_methods.rb:211: syntax error, unexpected tSTRING_BEG
def “performer”; missing_attribute(’“performer”’, caller) unless
@attributes.has_key?(’“performer”’); @attributes[’“performer”’]; end
^
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/
attribute_methods.rb:211: syntax error, unexpected kEND, expecting
$end
def “performer”; missing_attribute(’“performer”’, caller) unless
@attributes.has_key?(’“performer”’); @attributes[’“performer”’]; end

[…]

May there be any problem with the implementation of my database
driver? Maybe type conversion?
I googled but I was not able to find any hint to solve this or at
least things I should check.

Kind regards.