Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-74349

Fix TypeError: db.getDB is not a function

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • ALL
    • QO 2023-03-06
    • 60

      FeatureFlagUtil.isPresentAndEnabled() fails in the catch block inside if the object passed to it in is not Mongo object. We should pass `db.getMongo()` instead of just `db`:

              try {
                  setConn(db);
              } catch (err) {
                  // Some db-like objects (e.g. ShardingTest.shard0) aren't supported by FixtureHelpers,
                  // but we can replace it with an object that should work and try again.
                  setConn(db.getDB(db.defaultDB));
              }
      

      Other callees of the function pass db.getMongo() as well.

            Assignee:
            alexander.ignatyev@mongodb.com Alexander Ignatyev
            Reporter:
            alexander.ignatyev@mongodb.com Alexander Ignatyev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: