dolphindb 3.0.108 → 3.0.110

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/i18n/dict.json CHANGED
@@ -94,5 +94,8 @@
94
94
  },
95
95
  "发送至 DolphinDB 执行的脚本中间不能含有 \\0": {
96
96
  "en": "The script sent to DolphinDB for execution cannot contain \\0 in the middle"
97
+ },
98
+ "调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象": {
99
+ "en": "The parameters of calling ddb.invoke cannot contain both DdbObj and complex js native objects"
97
100
  }
98
101
  }
package/index.js CHANGED
@@ -3171,9 +3171,33 @@ export class DDB {
3171
3171
  ' args = cast(args, ANY)\n' +
3172
3172
  ' return unifiedCall(funcByName(func_name), args)\n' +
3173
3173
  '}\n', { urgent: true }));
3174
- if (options?.node)
3175
- options.func_type = DdbFunctionType.UserDefinedFunc;
3176
- return (await this.call(args?.length ? 'invoke' : func, args?.length ? [func, JSON.stringify(args)] : undefined, options)).data();
3174
+ // 检查 args 是否全部为简单参数,是则直接调用 call,避免 invoke 间接调用
3175
+ // 逻辑类似 DdbObj.to_ddbobjs, 需要同步修改
3176
+ let simple = true;
3177
+ let has_ddbobj = false;
3178
+ if (args)
3179
+ for (const arg of args) {
3180
+ if (arg && arg instanceof DdbObj)
3181
+ has_ddbobj = true;
3182
+ else {
3183
+ const type = typeof arg;
3184
+ if (type === 'string' || type === 'boolean') { }
3185
+ else {
3186
+ simple = false;
3187
+ break;
3188
+ }
3189
+ }
3190
+ }
3191
+ if (!simple) {
3192
+ if (has_ddbobj)
3193
+ throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
3194
+ if (options?.node)
3195
+ options.func_type = DdbFunctionType.UserDefinedFunc;
3196
+ }
3197
+ const result = simple
3198
+ ? await this.call(func, args, options)
3199
+ : await this.call('invoke', [func, JSON.stringify(args)], options);
3200
+ return result.data();
3177
3201
  }
3178
3202
  /** 执行 dolphindb 脚本,返回 js 原生对象或值(调用 DdbObj.data() 后的结果)
3179
3203
  - script?: 执行的脚本