[Nitro] fixtures not loaded in test database

Humber Aquino humberaquino at gmail.com
Wed Dec 28 08:02:01 EST 2005


I figure it out G!

When i assign an oid to mi fixture, it's updated rather than inserted,
and when you do that in mysql, nothing happens.

#The fixture that creates an update sql
user1:
 oid: 1
 name: John Doe
 telephone: '132312'
 username: jduser
 password: jdpassword

#The fixture that creates an insert statement. Whitout the  'oid: 1' line
user1:
 name: John Doe
 telephone: '132312'
 username: jduser
 password: jdpassword

I asign an oid because, in my real app, i have a has_many relationship
whit a class named Role.

class user
  ...
  has_many :roles, Role
  ...
end

class Role
  ...
  belongs_to :user, User
  ...
end

So in the role.yml, i assign an user_oid to a role so that role
belongs to a given user with that oid(Sorry for my english, it's quite
bad  +) ).
role1:
  user_oid: 1
  ....

The solution to the issue is know that the user fixtures will be
loaded in a secuential order and each oid depends of that order. If
someone tries to assign an oid, it will not be loaded, at least on
mysql(4.0.20)...

This is the sql statement generated by og when the oid is manualy assigned
UPDATE oguser SET name='John Doe', telephone='132312',
username='jduser', password='jdpassword' WHERE oid=1

if i execute this statement in any mysql client i get this:
mysql> UPDATE oguser SET name='John Doe', telephone='132312',
username='jduser', password='jdpassword' WHERE oid=1;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

Humber




More information about the Nitro-general mailing list