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

Ensure we accept nullishness as undefined or null

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.0
    • Affects Version/s: 4.0.0
    • Component/s: None
    • 2
    • Not Needed

      We should make sure we aren't strictly accepting null or undefined where either could be accepted. TS allows both null/undefined for optional parameters/properties.

      Here's an overview of the strict uses:

      6 results - 5 files
      
      src/collection.ts:
        1008    ): Promise<number> | void {
        1009:     if (typeof query === 'undefined') {
        1010        (query = {}), (options = {}), (callback = undefined);
      
      src/connection_string.ts:
        237      const [key, value] = keyValue.split(':');
        238:     if (typeof value === 'undefined') {
        239        throw new MongoParseError('Cannot have undefined values in key value pairs');
      
        279  ): MongoOptions {
        280:   if (typeof mongoClient !== 'undefined' && !(mongoClient instanceof MongoClient)) {
        281      options = mongoClient;
      
      src/error.ts:
        377  
        378:   if (typeof wireVersion !== 'undefined' && wireVersion >= 9) {
        379      // DRIVERS-1308: For 4.4 drivers running against 4.4 servers, drivers will add a special case to treat the CursorNotFound error code as resumable
      
      src/write_concern.ts:
        77    ): WriteConcern | undefined {
        78:     if (typeof options === 'undefined') return undefined;
        79      inherit = inherit ?? {};
      
      src/operations/estimated_document_count.ts:
        28    ) {
        29:     if (typeof options === 'undefined') {
        30        options = query as EstimatedDocumentCountOptions;
      
      
      5 results - 5 files
      
      src/explain.ts:
        39    static fromOptions(options?: ExplainOptions): Explain | undefined {
        40:     if (options?.explain === undefined) return;
        41  
      
      src/read_preference.ts:
        87      }
        88:     if (options === undefined && typeof tags === 'object' && !Array.isArray(tags)) {
        89        options = tags;
      
      src/cursor/aggregation_cursor.ts:
        85      if (typeof verbosity === 'function') (callback = verbosity), (verbosity = true);
        86:     if (verbosity === undefined) verbosity = true;
        87  
      
      src/cursor/find_cursor.ts:
        146      if (typeof verbosity === 'function') (callback = verbosity), (verbosity = true);
        147:     if (verbosity === undefined) verbosity = true;
        148  
      
      src/operations/command.ts:
        105      if (this.hasAspect(Aspect.EXPLAINABLE)) {
        106:       return this.explain === undefined;
        107      }
      
      
      2 results - 1 file
      
      src/cursor/abstract_cursor.ts:
        198      return {
        199:       next: () => this.next().then(value => ({ value, done: value === null }))
        200      };
      
        784  
        785:       if (result === null) {
        786          readable.push(null);
      
      

      Acceptance Criteria

      • Check that we do this, fix any places where we don't
      • Add or update existing tests

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Daria Pardue
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: