Fixture_references: "Mysql::Error #HY000"?


#1

I’ve been trying to use fixture references, and I seem to be getting
lots
of:

  1. Error:
    test_truth(DeviceTest):
    ActiveRecord::StatementInvalid: Mysql::Error: #HY000Field
    ‘description_id’ doesn
    ‘t have a default value: INSERT INTO devices (id) VALUES (2)
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection
    _adapters/abstract_adapter.rb:128:in log' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection _adapters/mysql_adapter.rb:243:inexecute’
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixtures.r
    b:290:in insert_fixtures' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixtures.r b:289:ineach’
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixtures.r
    b:289:in insert_fixtures' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixtures.r b:257:increate_fixtures_without_references’
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixtures.r
    b:257:in each' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixtures.r b:257:increate_fixtures_without_references’
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection
    _adapters/abstract/database_statements.rb:59:in transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixtures.r b:255:increate_fixtures_without_references’
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:86
    7:in silence' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixtures.r b:248:increate_fixtures_without_references’
    /home/hgs/aeg_intranet/csestore/config/…/vendor/plugins/fixture_references/
    lib/fixture_references.rb:92:in create_fixtures' /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixtures.r b:593:inload_fixtures’
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixtures.r
    b:538:in `setup’

But AFAICS the fixture data looks OK

Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html

<%
fixtures :devices, :descriptions
%>
olympus400_in:
id: 1
description_id: <%= descriptions(:C_400, ‘id’) %>
serialno: 238553902
barcode: 16301
state: ‘in stock’
categorypath: ‘Still Picture Camera’
lock_version: 1

and I tried the old form
description_id: <%= descriptions(:C_400)[‘id’] %>

but get the same error. The data does exist in the descriptions table:

C_400:
:text: Olympus C-400 Zoom
:id: 7
:picture: “”

What is puzzling me is that 1) I don’t assume a default, 2) MySQL error
numbers are normally purely numeric, and google maps this HY000 to many
things…

Any idea what I should be looking at for this, please? This is
rails 1.2.3 under cygwin.

    Thank you,
    Hugh