#137 ✓not-applicable

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

Reported by Paul | May 2nd, 2008 @ 03:55 PM

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 (dkubb)
  • 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 set 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.


    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
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 4th, 2008 @ 02:41 AM

    • Tag changed from dm-core, dm-more, dm_is_a_tree to dm-core, dm-more
    • State changed from “new” to “not-applicable”

    Marking this ticket as not-applicable because the SQL shown in the example is from the DM 0.3.x series, and the dm_is_a_tree plugin was renamed to dm-is-tree and completely updated.

    If you have the same issue with edge DataMapper and dm-is-tree please resubmit another ticket and include example models (and ideally a stand-alone script_ so that we can more easily reproduce the error.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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