handle empty result in table init master
authorJustin Wind <justin.wind+git@gmail.com>
Tue, 20 May 2025 18:31:10 +0000 (11:31 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Tue, 20 May 2025 18:31:10 +0000 (11:31 -0700)
lib/postgres-creator.js
test/lib/postgres-creator.js

index dc0ee93e702c11773e902e63e53a02ff18d6a4f5..d2e5ca9de34b104954c0088b15b771d8d8748a90 100644 (file)
@@ -78,8 +78,10 @@ const PostgresCreator = (Abstract) => {
      * @returns {object[]} scrubbed results
      */
     static _multiResultLog(results) {
      * @returns {object[]} scrubbed results
      */
     static _multiResultLog(results) {
-      for (const result of results) {
-        delete result._types;
+      if (results) {
+        for (const result of results) {
+          delete result._types;
+        }
       }
       return results;
     }
       }
       return results;
     }
index ecc60259ccf5d9ad62389bdee0027579f5f19438..b8a820cb8cb30083128cd4a1e26b91b46d20eac8 100644 (file)
@@ -128,6 +128,17 @@ describe('Postgres Creator', function () {
     }); // receive
   }); // pgpInitOptions
 
     }); // receive
   }); // pgpInitOptions
 
+  describe('_multiResultLog', function () {
+    it('strips verbosity', function () {
+      const result = DatabasePostgres._multiResultLog(multiResultResponse);
+      assert(!('_types' in result[0]));
+    });
+    it('covers empty', function () {
+      const result = DatabasePostgres._multiResultLog(undefined);
+      assert.strictEqual(result, undefined);
+    });
+  }); // _multiResultLog
+
   describe('_tableExists', function () {
     beforeEach(function () {
       sinon.stub(db.db, 'oneOrNone');
   describe('_tableExists', function () {
     beforeEach(function () {
       sinon.stub(db.db, 'oneOrNone');