You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2021/07/02 03:56:19 UTC

[zeppelin] branch branch-0.9 updated: [ZEPPELIN-5426] mongodb interpreter: support mongosh

This is an automated email from the ASF dual-hosted git repository.

zjffdu pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/branch-0.9 by this push:
     new 3088fc8  [ZEPPELIN-5426] mongodb interpreter: support mongosh
3088fc8 is described below

commit 3088fc892886b8f08142395a2e0f9a249c208980
Author: Christoph Nölle <19...@users.noreply.github.co>
AuthorDate: Thu Jun 24 01:02:37 2021 +0200

    [ZEPPELIN-5426] mongodb interpreter: support mongosh
    
    ### What is this PR for?
    The mongodb interpreter works by calling into the deprecated `mongo` shell (https://docs.mongodb.com/manual/reference/program/mongo/), which is going to be replaced by `mongosh` (https://docs.mongodb.com/mongodb-shell/). This is a largely backwards compatible migration, so that the interpreter works almost unchanged. Some internals have changed nevertheless, this pull request ensures the interpreter works with the new shell without breaking backwards compatibility.
    
    ### What type of PR is it?
    Improvement
    
    ### Todos
    
    ### What is the Jira issue?
    https://issues.apache.org/jira/browse/ZEPPELIN-5426
    
    ### How should this be tested?
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? At some point...
    
    Author: Christoph Nölle <19...@users.noreply.github.co>
    
    Closes #4152 from cnoelle/ZEPPELIN-5426 and squashes the following commits:
    
    caf608c36f [Christoph Nölle] mongodb interpreter: adapt shell extension for mongosh support
    
    (cherry picked from commit 19a963fea11632bda7f6be3b91ea319b06a7f998)
    Signed-off-by: Jeff Zhang <zj...@apache.org>
---
 mongodb/src/main/resources/shell_extension.js | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mongodb/src/main/resources/shell_extension.js b/mongodb/src/main/resources/shell_extension.js
index b50f500..ddaf2fc 100644
--- a/mongodb/src/main/resources/shell_extension.js
+++ b/mongodb/src/main/resources/shell_extension.js
@@ -97,14 +97,15 @@ function printTable(dbquery, fields, flattenArray) {
     });
 }
 
-DBQuery.prototype.table = function (fields, flattenArray) {
+(DBQuery.prototype || DBQuery).table = function (fields, flattenArray) {
     if (this._limit > tableLimit) {
         this.limit(tableLimit);
     }
     printTable(this, fields, flattenArray);
 };
 
-DBCommandCursor.prototype.table = DBQuery.prototype.table;
+if (globalThis.DBCommandCursor)
+    (DBCommandCursor.prototype || DBCommandCursor).table = (DBQuery.prototype || DBQuery).table;
 
 var userName = "USER_NAME_PLACEHOLDER";
 var password = "PASSWORD_PLACEHOLDER";