[Groonga-commit] groonga/gcs [master] Fix error around Domain#dump() for blank domain

Zurück zum Archiv-Index

SHIMODA Hiroshi null+****@clear*****
Mon Aug 13 12:08:10 JST 2012


SHIMODA Hiroshi	2012-08-13 12:08:10 +0900 (Mon, 13 Aug 2012)

  New Revision: cde9b4f181962b7a252a35623be176fe2dccaf04
  https://github.com/groonga/gcs/commit/cde9b4f181962b7a252a35623be176fe2dccaf04

  Log:
    Fix error around Domain#dump() for blank domain

  Modified files:
    lib/database/domain.js
    test/database-domain.test.js

  Modified: lib/database/domain.js (+2 -0)
===================================================================
--- lib/database/domain.js    2012-08-13 11:49:49 +0900 (6f5bcf8)
+++ lib/database/domain.js    2012-08-13 12:08:10 +0900 (4ada171)
@@ -327,6 +327,8 @@ Domain.prototype = {
                });
 
     var tableContents = dump.split('load --table ' + this.tableName)[1];
+        // if the table is blank, tableContents becomes undefined.
+    if (!tableContents) return [];
     tableContents = JSON.parse(tableContents);
 
     var columnNames = tableContents[0];

  Modified: test/database-domain.test.js (+9 -1)
===================================================================
--- test/database-domain.test.js    2012-08-13 11:49:49 +0900 (ccbcc19)
+++ test/database-domain.test.js    2012-08-13 12:08:10 +0900 (ef15a6f)
@@ -408,7 +408,6 @@ suite('database', function() {
         temporaryDatabase = utils.createTemporaryDatabase();
         context = temporaryDatabase.get();
         utils.loadDumpFile(context, __dirname + '/fixture/companies/ddl.grn');
-        utils.loadDumpFile(context, __dirname + '/fixture/companies/data.grn');
         domain = new Domain('companies', context);
       });
 
@@ -418,7 +417,14 @@ suite('database', function() {
         temporaryDatabase = undefined;
       });
 
+      test('dump for blank domain', function() {
+        var actualDump = domain.dump();
+        assert.deepEqual(actualDump, []);
+      });
+
       test('dump', function() {
+        utils.loadDumpFile(context, __dirname + '/fixture/companies/data.grn');
+
         var actualDump = domain.dump();
         assert.isTrue(Array.isArray(actualDump), actualDump);
         assert.equal(actualDump.length, 10, actualDump);
@@ -450,6 +456,8 @@ suite('database', function() {
       });
 
       test('load', function() {
+        utils.loadDumpFile(context, __dirname + '/fixture/companies/data.grn');
+
         var values = [
               { id: 'id10',
                 description: 'updated',
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index