Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2060

can't use database named 'constructor'

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.0
    • Affects Version/s: 3.2.7
    • Component/s: Native
    • Environment:
      NodeJS v.8.11.4
      discovered the issue on Windows, but Linux seems to be affected as well.
      mongoose is affected too, but I've distilled the example to using pure mongodb module.
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Trying to connect to database called "constructor" breaks something. The following code demonstrates the issue:

      const mongo = require('mongodb').MongoClient;
      const goodUrl = 'mongodb://localhost:27017/constructor1';
      const badUrl = 'mongodb://localhost:27017/constructor';
      
      mongo.connect(goodUrl, {useNewUrlParser : true})
      .then(client => {
         let db = client.db();
         console.log('good:', typeof db); // 'good: object'
      });
      
      mongo.connect(badUrl, {useNewUrlParser : true})
      .then(client => {
         let db = client.db();
         console.log('bad:', typeof db); // 'bad: function'
      });
      

      Basically, any database name work fine, except "constructor"

            Assignee:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Reporter:
            ant1973@gmail.com Anatoly Melnikov
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: