Note that there are some explanatory texts on larger screens.

plurals
  1. PODataMapper Associations, simple code, not working
    text
    copied!<p>I'm just begining to use DataMappers associations, just to test things out have a very simple table structure, and it's is borking.</p> <pre><code>require 'dm-core' require 'dm-migrations' DataMapper.setup( :default, "sqlite3://#{Dir.pwd}/dbtest.db" ) class Account include DataMapper::Resource property :id, Serial has 1, :userprofile, :model =&gt;"UserProfile" end class UserProfile include DataMapper::Resource property :id, Serial belongs_to :Account end DataMapper.finalize #whether I have this before or after auto migrate the result is the same DataMapper.auto_migrate! </code></pre> <p>This should just work, nice and simple, DM is working for everything else(I'e already been using it plenty).</p> <p>Here is the result when I run this code, anyone know what the problem is?:</p> <pre><code>DataObjects::SyntaxError: duplicate column name: account_id (code: 1, sql state: , query: CREATE TABLE "user_profiles" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "account_id" INTEGER NOT NULL, "account_id" INTEGER NOT NULL), uri: sqlite3://d/Borrow/dbtest.db) from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/adapters/dm-do-adapter.rb:92:in `execute_non_query' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/adapters/dm-do-adapter.rb:92:in `create_model_storage' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/adapters/dm-do-adapter.rb:90:in `each' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/adapters/dm-do-adapter.rb:90:in `create_model_storage' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-do-adapter-1.0.0/lib/dm-do-adapter/adapter.rb:260:in `with_connection' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/adapters/dm-do-adapter.rb:85:in `create_model_storage' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/auto_migration.rb:79:in `create_model_storage' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/auto_migration.rb:175:in `auto_migrate_up!' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/auto_migration.rb:130:in `auto_migrate!' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/auto_migration.rb:45:in `send' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/auto_migration.rb:45:in `repository_execute' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-core-1.0.0/lib/dm-core/model/descendant_set.rb:33:in `each' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-core-1.0.0/lib/dm-core/model/descendant_set.rb:33:in `each' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/auto_migration.rb:44:in `repository_execute' from d:/Ruby/lib/ruby/gems/1.8/gems/dm-migrations-1.0.0/lib/dm-migrations/auto_migration.rb:22:in `auto_migrate!' </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload