#137 new
Paul

Not unique table/alias: 'lists' (mysql_error_code=0001)

Reported by Paul | January 24th, 2008 @ 05:06 AM

When use dm_is_a_tree (or not) and try to :include childrens in finder (for preloading), dm create bad sql query

Category.all(:parent_id => 0, :order => 'position', :include => [:children])

Your query failed. Not unique table/alias: 'categories' SELECT `categories`.`id`, `categories`.`name`, `categories`.`link`, `categories`.`parent_id`, `categories`.`categories_count`, `categories`.`id`, `categories`.`name`, `categories`.`link`, `categories`.`parent_id`, `categories`.`categories_count` FROM `categories` JOIN `categories` ON `categories`.`parent_id` = `categories`.`id` WHERE (categories.parent_id = 0) ORDER BY categories.position

Comments and changes to this ticket

  • Dan Kubb

    Dan Kubb April 15th, 2008 @ 03:29 AM

      • → Milestone cleared.
  • Sam Smoot

    Sam Smoot May 9th, 2008 @ 12:04 AM

    What version of DM is this?

  • will

    will August 11th, 2008 @ 06:30 PM

      • → Title changed from “self referential (tree) cause sql error when finder :include childrens” to “Not unique table/alias: 'lists' (mysql_error_code=0001)”
      • → Tag changed from “” to “dm-core dm-more dm_is_a_tree”

    I'm getting this error running on edge.

    I'm new to DM, but I thought this syntax should work from the documentation I've seen so far.

    ResourcePermission.all(:user_id=>1).list.list_items

    associations are: List has n, :resource_permissions List has n, :list_items ListItem belongs_to :list ResourcePermission belongs_to :list, :child_key=>[:resource_id]

    Mon, 11 Aug 2008 23:17:05 GMT ~ debug ~ SELECT list_items.id, list_items.list_id, list_items.created_at, list_items.created_by, list_items.updated_at, list_items.updated_by, list_items.deleted_by FROM list_items INNER JOIN lists ON lists.id = resource_permissions.resource_id INNER JOIN lists ON lists.id = list_items.list_id WHERE list_items.deleted_at IS NULL AND lists.deleted_at IS NULL AND resource_permissions.deleted_at IS NULL AND resource_permissions.user_id = 1 ORDER BY list_items.id Mon, 11 Aug 2008 23:17:05 GMT ~ debug ~ Not unique table/alias: 'lists' (mysql_error_code=0001) Mon, 11 Aug 2008 23:17:05 GMT ~ debug ~ #<DataObjects::Mysql::Connection:0x1c8304c @using_socket=false, @concrete_command=DataObjects::Mysql::Command, @uri=#<Addressable::URI:0xe92fb4 URI:mysql://zenbe@localhost/zenbe_dev_lists>, @allocated_in_pool=Mon Aug 11 19:17:05 -0400 2008, @connection=#<Object:0x1c82f20>, @pool=#<Extlib::Pooling::Pool<DataObjects::Mysql::Connection> available=0 reserved_count=1>> Mon, 11 Aug 2008 23:17:05 GMT ~ error ~ Not unique table/alias: 'lists' (mysql_error_code=0001) Mysql::Error: Not unique table/alias: 'lists' (mysql_error_code=0001)

    from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.4/lib/dm-core/adapters/data_objects_adapter.rb:45:in `execute_reader'
    from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.4/lib/dm-core/adapters/data_objects_adapter.rb:45:in `read_many'
    from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.4/lib/dm-core/adapters/data_objects_adapter.rb:168:in `with_connection'
    from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.4/lib/dm-core/adapters/data_objects_adapter.rb:40:in `read_many'
    from /usr/local/lib/ruby/gems/1.8/gems/extlib-0.9.4/lib/extlib/lazy_array.rb:89:in `[]'
    from /usr/local/lib/ruby/gems/1.8/gems/extlib-0.9.4/lib/extlib/lazy_array.rb:89:in `lazy_load'
    from /usr/local/lib/ruby/gems/1.8/gems/extlib-0.9.4/lib/extlib/lazy_array.rb:23:in `inspect'
    from /usr/local/lib/ruby/1.8/irb.rb:298:in `output_value'
    from /usr/local/lib/ruby/1.8/irb.rb:151:in `eval_input'
    from /usr/local/lib/ruby/1.8/irb.rb:259:in `signal_status'
    from /usr/local/lib/ruby/1.8/irb.rb:147:in `eval_input'
    from /usr/local/lib/ruby/1.8/irb.rb:146:in `eval_input'
    from /usr/local/lib/ruby/1.8/irb.rb:70:in `start'
    from /usr/local/lib/ruby/1.8/irb.rb:69:in `catch'
    from /usr/local/lib/ruby/1.8/irb.rb:69:in `start'
    from /usr/local/bin/irb:13
    

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins