dolphindb 3.0.124 → 3.0.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/browser.js CHANGED
@@ -558,7 +558,7 @@ export class DdbObj {
558
558
  type,
559
559
  length: i_items_start + len_items,
560
560
  cols: 1,
561
- rows,
561
+ rows: type === DdbType.iotany ? value.length : rows,
562
562
  value,
563
563
  ...type === DdbType.iotany ? { buffer: buf } : {}
564
564
  });
@@ -2968,46 +2968,52 @@ export class DDB {
2968
2968
  await this.connect();
2969
2969
  const { script, func, args: _args = [], vars = [], urgent, listener, on_more_messages, } = options;
2970
2970
  if (func === 'pnode_run')
2971
- await (this.ppnode_run ??= this.eval(this.python ?
2972
- '\n' +
2973
- 'def pnode_run (nodes, func_name, args, add_node_alias):\n' +
2974
- ' nargs = size(args)\n' +
2975
- ' func = funcByName(func_name)\n' +
2976
- ' \n' +
2977
- ' if not nargs:\n' +
2978
- ' return pnodeRun(func, nodes, add_node_alias)\n' +
2979
- ' \n' +
2980
- ' args_partial = [ ]\n' +
2981
- ' args_partial.append(func)\n' +
2982
- ' for a in args:\n' +
2983
- ' args_partial.append(a)\n' +
2984
- ' \n' +
2985
- ' return pnodeRun(\n' +
2986
- ' unifiedCall(partial, args_partial),\n' +
2987
- ' nodes,\n' +
2988
- ' add_node_alias\n' +
2989
- ' )\n'
2990
- :
2991
- // 这个开头的空行很重要,应该可以绕过 webLoginRequired = true 时禁止执行代码
2992
- // 搜一下 APISocketConsole::execute
2993
- // https://dolphindb1.atlassian.net/browse/D20-4991
2971
+ try {
2972
+ await (this.ppnode_run ??= this.eval(this.python ?
2994
2973
  '\n' +
2995
- 'def pnode_run (nodes, func_name, args, add_node_alias = true) {\n' +
2974
+ 'def pnode_run (nodes, func_name, args, add_node_alias):\n' +
2996
2975
  ' nargs = size(args)\n' +
2997
2976
  ' func = funcByName(func_name)\n' +
2998
2977
  ' \n' +
2999
- ' if (!nargs)\n' +
2978
+ ' if not nargs:\n' +
3000
2979
  ' return pnodeRun(func, nodes, add_node_alias)\n' +
3001
2980
  ' \n' +
3002
- ' args_partial = array(any, 1 + nargs, 1 + nargs)\n' +
3003
- ' args_partial[0] = func\n' +
3004
- ' args_partial[1:] = args\n' +
2981
+ ' args_partial = [ ]\n' +
2982
+ ' args_partial.append(func)\n' +
2983
+ ' for a in args:\n' +
2984
+ ' args_partial.append(a)\n' +
2985
+ ' \n' +
3005
2986
  ' return pnodeRun(\n' +
3006
2987
  ' unifiedCall(partial, args_partial),\n' +
3007
2988
  ' nodes,\n' +
3008
2989
  ' add_node_alias\n' +
3009
- ' )\n' +
3010
- '}\n', { urgent: true }));
2990
+ ' )\n'
2991
+ :
2992
+ // 这个开头的空行很重要,应该可以绕过 webLoginRequired = true 时禁止执行代码
2993
+ // 搜一下 APISocketConsole::execute
2994
+ // https://dolphindb1.atlassian.net/browse/D20-4991
2995
+ '\n' +
2996
+ 'def pnode_run (nodes, func_name, args, add_node_alias = true) {\n' +
2997
+ ' nargs = size(args)\n' +
2998
+ ' func = funcByName(func_name)\n' +
2999
+ ' \n' +
3000
+ ' if (!nargs)\n' +
3001
+ ' return pnodeRun(func, nodes, add_node_alias)\n' +
3002
+ ' \n' +
3003
+ ' args_partial = array(any, 1 + nargs, 1 + nargs)\n' +
3004
+ ' args_partial[0] = func\n' +
3005
+ ' args_partial[1:] = args\n' +
3006
+ ' return pnodeRun(\n' +
3007
+ ' unifiedCall(partial, args_partial),\n' +
3008
+ ' nodes,\n' +
3009
+ ' add_node_alias\n' +
3010
+ ' )\n' +
3011
+ '}\n', { urgent: true }));
3012
+ }
3013
+ catch (error) {
3014
+ this.ppnode_run = undefined;
3015
+ throw error;
3016
+ }
3011
3017
  // this 上的当前配置需要在 message 到达后使用,先保存起来
3012
3018
  const _listeners = [...this.listeners].reverse();
3013
3019
  // rpc 请求期间需要独占 websocket,所以设计了一个锁,申请之后才能使用
@@ -3234,34 +3240,6 @@ export class DDB {
3234
3240
  - add_node_alias?: 设置 nodes 参数时选传,其它情况不传
3235
3241
  - listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
3236
3242
  async invoke(func, args, options) {
3237
- try {
3238
- await (this.pinvoke ??= this.eval(this.python ?
3239
- '\n' +
3240
- 'def invoke (func, args_json):\n' +
3241
- ' args = fromStdJson(args_json)\n' +
3242
- ' func_ = func\n' +
3243
- ' if type(func) == STRING:\n' +
3244
- ' func_ = funcByName(func)\n' +
3245
- ' if type(args) != ANY:\n' +
3246
- ' args = cast(args, ANY)\n' +
3247
- ' return unifiedCall(func_, args)\n'
3248
- :
3249
- '\n' +
3250
- 'def invoke (func, args_json) {\n' +
3251
- ' args = fromStdJson(args_json)\n' +
3252
- ' func_ = func\n' +
3253
- ' if (type(func) == STRING)\n' +
3254
- ' func_ = funcByName(func)\n' +
3255
- ' if (type(args) != ANY)\n' +
3256
- ' args = cast(args, ANY)\n' +
3257
- ' return unifiedCall(func_, args)\n' +
3258
- '}\n', { urgent: true }));
3259
- }
3260
- catch (error) {
3261
- // invoke 没有正确执行时,重新将 pinvoke 赋值为 undefined
3262
- this.pinvoke = undefined;
3263
- throw error;
3264
- }
3265
3243
  // 检查 args 是否全部为简单参数,是则直接调用 call,避免 invoke 间接调用
3266
3244
  // 逻辑类似 DdbObj.to_ddbobjs, 需要同步修改
3267
3245
  let simple = true;
@@ -3278,11 +3256,42 @@ export class DDB {
3278
3256
  break;
3279
3257
  }
3280
3258
  }
3281
- if (!simple && has_ddbobj)
3282
- throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
3283
- const result = simple
3284
- ? await this.call(func, args, options)
3285
- : await this.call('invoke', [func, JSON.stringify(args)], options);
3259
+ let result;
3260
+ if (simple)
3261
+ result = await this.call(func, args, options);
3262
+ else {
3263
+ if (has_ddbobj)
3264
+ throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
3265
+ try {
3266
+ await (this.pinvoke ??= this.eval(this.python ?
3267
+ '\n' +
3268
+ 'def invoke (func, args_json):\n' +
3269
+ ' args = fromStdJson(args_json)\n' +
3270
+ ' func_ = func\n' +
3271
+ ' if type(func) == STRING:\n' +
3272
+ ' func_ = funcByName(func)\n' +
3273
+ ' if type(args) != ANY:\n' +
3274
+ ' args = cast(args, ANY)\n' +
3275
+ ' return unifiedCall(func_, args)\n'
3276
+ :
3277
+ '\n' +
3278
+ 'def invoke (func, args_json) {\n' +
3279
+ ' args = fromStdJson(args_json)\n' +
3280
+ ' func_ = func\n' +
3281
+ ' if (type(func) == STRING)\n' +
3282
+ ' func_ = funcByName(func)\n' +
3283
+ ' if (type(args) != ANY)\n' +
3284
+ ' args = cast(args, ANY)\n' +
3285
+ ' return unifiedCall(func_, args)\n' +
3286
+ '}\n', { urgent: true }));
3287
+ }
3288
+ catch (error) {
3289
+ // invoke 没有正确执行时,重新将 pinvoke 赋值为 undefined
3290
+ this.pinvoke = undefined;
3291
+ throw error;
3292
+ }
3293
+ result = await this.call('invoke', [func, JSON.stringify(args)], options);
3294
+ }
3286
3295
  return result.data(options);
3287
3296
  }
3288
3297
  /** 执行 dolphindb 脚本,返回 js 原生对象或值(调用 DdbObj.data() 后的结果)