I'm trying to count associated items and here is code:
--cut--
require 'rubygems'
gem 'dm-core', '0.10.0'
require 'dm-core'
DataMapper.setup(:default, 'postgres://pass:lo...@host/db')
class Article
include DataMapper::Resource
property :id, Serial
property :title, String
property :content, Text
end
class Tag
include DataMapper::Resource
property :id, Serial
property :tag, String
end
class Tagging
include DataMapper::Resource
property :id, Serial
belongs_to :tag
belongs_to :article
end
class Article
has n, :taggings
has n, :tags, :through => :taggings
end
class Tag
has n, :taggings
has n, :articles, :through => :taggings
end
Tag.auto_upgrade!
Article.auto_upgrade!
Tagging.auto_upgrade!
.
... inserting some data...
.
puts Article.all('tags.tag' => 'sometag').count
--cut--
end here we are:
/usr/lib64/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/adapters/
data_objects_adapter.rb:85:in `execute_reader': ERROR: missing FROM-
clause entry for table "tags" (PostgresError)
LINE 1: ...."title" FROM "articles" INNER JOIN "taggings" ON
"tags"."id...
^
Query: SELECT "articles"."id", "articles"."title" FROM "articles"
INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" INNER JOIN
"articles" ON "taggings"."article_id" = "articles"."id" WHERE
"tags"."tag" = 'sometag' GROUP BY "articles"."id", "articles"."title"
ORDER BY "articles"."id"
from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/
adapters/data_objects_adapter.rb:85:in `read'
from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/
adapters/data_objects_adapter.rb:253:in `with_connection'
from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/
adapters/data_objects_adapter.rb:81:in `read'
from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/
repository.rb:145:in `read'
from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/
collection.rb:982:in `lazy_load'
from /usr/lib64/ruby/gems/1.8/gems/extlib-0.9.12/lib/extlib/
lazy_array.rb:461:in `count'
with do_sqlite3 error is more-or-less the same, it looks like some
kind of a bug
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---