Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3668

Inconsistencies with dynamic collections

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      I have noticed inconsistent behaviour when using the

      Unable to find source-code formatter for language: with. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      (collection: collection_name)

      modifier to force mongoid to read from / write to a different collection.

      First of all this doesn't work as expected:

      Search.with(collection: "search_collection_1").where(...)
      

      doesn't work. Instead you need to add

      Unable to find source-code formatter for language: all```. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
       to make it work, like:
      

      ruby
      Search.all.with(collection: "search_collection_1").where(...)

      
      Furthermore, when I create a new object with 

      with

       then consequent updates to the object use the correct collection, i.e:
      

      ruby
      search = Search.with(collection: "search_collection_1").create(id: "xyz", data1: "some useful data...")
      search.inc(usage: 1) # this will update the document in the correct collection

      
      However during retrieval this is not the case:
      

      ruby
      search = Search.with(collection: "search_collection_1").where(id: "xyz").first
      search.inc(usage: 1) # this will update the document in the default "searches" collection (practically it will do nothing, since the document is not there)

      search.with(collection: "search_collection_1")
      search.inc(usage: 2) # now it use the proper collection
      `

      Is this something that will be fixed?
      Or is it supposed to work like this?

            Assignee:
            Unassigned Unassigned
            Reporter:
            glampr glampr
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: