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/index.js CHANGED
@@ -555,7 +555,7 @@ export class DdbObj {
555
555
  type,
556
556
  length: i_items_start + len_items,
557
557
  cols: 1,
558
- rows,
558
+ rows: type === DdbType.iotany ? value.length : rows,
559
559
  value,
560
560
  ...type === DdbType.iotany ? { buffer: buf } : {}
561
561
  });
@@ -2946,46 +2946,52 @@ export class DDB {
2946
2946
  await this.connect();
2947
2947
  const { script, func, args: _args = [], vars = [], urgent, listener, on_more_messages, } = options;
2948
2948
  if (func === 'pnode_run')
2949
- await (this.ppnode_run ??= this.eval(this.python ?
2950
- '\n' +
2951
- 'def pnode_run (nodes, func_name, args, add_node_alias):\n' +
2952
- ' nargs = size(args)\n' +
2953
- ' func = funcByName(func_name)\n' +
2954
- ' \n' +
2955
- ' if not nargs:\n' +
2956
- ' return pnodeRun(func, nodes, add_node_alias)\n' +
2957
- ' \n' +
2958
- ' args_partial = [ ]\n' +
2959
- ' args_partial.append(func)\n' +
2960
- ' for a in args:\n' +
2961
- ' args_partial.append(a)\n' +
2962
- ' \n' +
2963
- ' return pnodeRun(\n' +
2964
- ' unifiedCall(partial, args_partial),\n' +
2965
- ' nodes,\n' +
2966
- ' add_node_alias\n' +
2967
- ' )\n'
2968
- :
2969
- // 这个开头的空行很重要,应该可以绕过 webLoginRequired = true 时禁止执行代码
2970
- // 搜一下 APISocketConsole::execute
2971
- // https://dolphindb1.atlassian.net/browse/D20-4991
2949
+ try {
2950
+ await (this.ppnode_run ??= this.eval(this.python ?
2972
2951
  '\n' +
2973
- 'def pnode_run (nodes, func_name, args, add_node_alias = true) {\n' +
2952
+ 'def pnode_run (nodes, func_name, args, add_node_alias):\n' +
2974
2953
  ' nargs = size(args)\n' +
2975
2954
  ' func = funcByName(func_name)\n' +
2976
2955
  ' \n' +
2977
- ' if (!nargs)\n' +
2956
+ ' if not nargs:\n' +
2978
2957
  ' return pnodeRun(func, nodes, add_node_alias)\n' +
2979
2958
  ' \n' +
2980
- ' args_partial = array(any, 1 + nargs, 1 + nargs)\n' +
2981
- ' args_partial[0] = func\n' +
2982
- ' args_partial[1:] = args\n' +
2959
+ ' args_partial = [ ]\n' +
2960
+ ' args_partial.append(func)\n' +
2961
+ ' for a in args:\n' +
2962
+ ' args_partial.append(a)\n' +
2963
+ ' \n' +
2983
2964
  ' return pnodeRun(\n' +
2984
2965
  ' unifiedCall(partial, args_partial),\n' +
2985
2966
  ' nodes,\n' +
2986
2967
  ' add_node_alias\n' +
2987
- ' )\n' +
2988
- '}\n', { urgent: true }));
2968
+ ' )\n'
2969
+ :
2970
+ // 这个开头的空行很重要,应该可以绕过 webLoginRequired = true 时禁止执行代码
2971
+ // 搜一下 APISocketConsole::execute
2972
+ // https://dolphindb1.atlassian.net/browse/D20-4991
2973
+ '\n' +
2974
+ 'def pnode_run (nodes, func_name, args, add_node_alias = true) {\n' +
2975
+ ' nargs = size(args)\n' +
2976
+ ' func = funcByName(func_name)\n' +
2977
+ ' \n' +
2978
+ ' if (!nargs)\n' +
2979
+ ' return pnodeRun(func, nodes, add_node_alias)\n' +
2980
+ ' \n' +
2981
+ ' args_partial = array(any, 1 + nargs, 1 + nargs)\n' +
2982
+ ' args_partial[0] = func\n' +
2983
+ ' args_partial[1:] = args\n' +
2984
+ ' return pnodeRun(\n' +
2985
+ ' unifiedCall(partial, args_partial),\n' +
2986
+ ' nodes,\n' +
2987
+ ' add_node_alias\n' +
2988
+ ' )\n' +
2989
+ '}\n', { urgent: true }));
2990
+ }
2991
+ catch (error) {
2992
+ this.ppnode_run = undefined;
2993
+ throw error;
2994
+ }
2989
2995
  // this 上的当前配置需要在 message 到达后使用,先保存起来
2990
2996
  const _listeners = [...this.listeners].reverse();
2991
2997
  // rpc 请求期间需要独占 websocket,所以设计了一个锁,申请之后才能使用
@@ -3212,34 +3218,6 @@ export class DDB {
3212
3218
  - add_node_alias?: 设置 nodes 参数时选传,其它情况不传
3213
3219
  - listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
3214
3220
  async invoke(func, args, options) {
3215
- try {
3216
- await (this.pinvoke ??= this.eval(this.python ?
3217
- '\n' +
3218
- 'def invoke (func, args_json):\n' +
3219
- ' args = fromStdJson(args_json)\n' +
3220
- ' func_ = func\n' +
3221
- ' if type(func) == STRING:\n' +
3222
- ' func_ = funcByName(func)\n' +
3223
- ' if type(args) != ANY:\n' +
3224
- ' args = cast(args, ANY)\n' +
3225
- ' return unifiedCall(func_, args)\n'
3226
- :
3227
- '\n' +
3228
- 'def invoke (func, args_json) {\n' +
3229
- ' args = fromStdJson(args_json)\n' +
3230
- ' func_ = func\n' +
3231
- ' if (type(func) == STRING)\n' +
3232
- ' func_ = funcByName(func)\n' +
3233
- ' if (type(args) != ANY)\n' +
3234
- ' args = cast(args, ANY)\n' +
3235
- ' return unifiedCall(func_, args)\n' +
3236
- '}\n', { urgent: true }));
3237
- }
3238
- catch (error) {
3239
- // invoke 没有正确执行时,重新将 pinvoke 赋值为 undefined
3240
- this.pinvoke = undefined;
3241
- throw error;
3242
- }
3243
3221
  // 检查 args 是否全部为简单参数,是则直接调用 call,避免 invoke 间接调用
3244
3222
  // 逻辑类似 DdbObj.to_ddbobjs, 需要同步修改
3245
3223
  let simple = true;
@@ -3256,11 +3234,42 @@ export class DDB {
3256
3234
  break;
3257
3235
  }
3258
3236
  }
3259
- if (!simple && has_ddbobj)
3260
- throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
3261
- const result = simple
3262
- ? await this.call(func, args, options)
3263
- : await this.call('invoke', [func, JSON.stringify(args)], options);
3237
+ let result;
3238
+ if (simple)
3239
+ result = await this.call(func, args, options);
3240
+ else {
3241
+ if (has_ddbobj)
3242
+ throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
3243
+ try {
3244
+ await (this.pinvoke ??= this.eval(this.python ?
3245
+ '\n' +
3246
+ 'def invoke (func, args_json):\n' +
3247
+ ' args = fromStdJson(args_json)\n' +
3248
+ ' func_ = func\n' +
3249
+ ' if type(func) == STRING:\n' +
3250
+ ' func_ = funcByName(func)\n' +
3251
+ ' if type(args) != ANY:\n' +
3252
+ ' args = cast(args, ANY)\n' +
3253
+ ' return unifiedCall(func_, args)\n'
3254
+ :
3255
+ '\n' +
3256
+ 'def invoke (func, args_json) {\n' +
3257
+ ' args = fromStdJson(args_json)\n' +
3258
+ ' func_ = func\n' +
3259
+ ' if (type(func) == STRING)\n' +
3260
+ ' func_ = funcByName(func)\n' +
3261
+ ' if (type(args) != ANY)\n' +
3262
+ ' args = cast(args, ANY)\n' +
3263
+ ' return unifiedCall(func_, args)\n' +
3264
+ '}\n', { urgent: true }));
3265
+ }
3266
+ catch (error) {
3267
+ // invoke 没有正确执行时,重新将 pinvoke 赋值为 undefined
3268
+ this.pinvoke = undefined;
3269
+ throw error;
3270
+ }
3271
+ result = await this.call('invoke', [func, JSON.stringify(args)], options);
3272
+ }
3264
3273
  return result.data(options);
3265
3274
  }
3266
3275
  /** 执行 dolphindb 脚本,返回 js 原生对象或值(调用 DdbObj.data() 后的结果)