@rex0220/kintone-sql-tools 3.59.0 → 3.60.0
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/dist-cli/ksql.js +104 -33
- package/dist-engine/index.cjs +11 -11
- package/dist-engine/index.mjs +11 -11
- package/dist-engine/ksql-engine.umd.js +12 -12
- package/dist-engine/meta/bundle-baseline.json +10 -10
- package/dist-engine/meta/cjs.json +44 -7
- package/dist-engine/meta/esm.json +44 -7
- package/dist-engine/meta/umd.json +44 -7
- package/dist-mcp/ksql-mcp.js +108 -35
- package/dist-mcpb/ksql-mcp.mcpb +0 -0
- package/package.json +1 -1
package/dist-cli/ksql.js
CHANGED
|
@@ -3187,7 +3187,7 @@ var Parser = class {
|
|
|
3187
3187
|
return { type: "BINARY", op: "KLIKE", left: field, right: pattern };
|
|
3188
3188
|
}
|
|
3189
3189
|
const op = this.parseCompareOp();
|
|
3190
|
-
const right = this.parseWhereSqlValue();
|
|
3190
|
+
const right = this.parseWhereSqlValue(op !== "LIKE");
|
|
3191
3191
|
return { type: "BINARY", op, left: field, right };
|
|
3192
3192
|
}
|
|
3193
3193
|
parseCompareOp() {
|
|
@@ -3310,8 +3310,13 @@ var Parser = class {
|
|
|
3310
3310
|
return { type: "FIELD", tableAlias: qi.tableAlias, field: qi.field };
|
|
3311
3311
|
}
|
|
3312
3312
|
// 右辺の値
|
|
3313
|
-
parseWhereSqlValue() {
|
|
3313
|
+
parseWhereSqlValue(allowUnaryPlusNumberLiteral = true) {
|
|
3314
3314
|
const tok = this.peek();
|
|
3315
|
+
if (allowUnaryPlusNumberLiteral && tok.kind === "+" /* PLUS */) {
|
|
3316
|
+
this.advance();
|
|
3317
|
+
const number = this.expect("NUMBER" /* NUMBER */, "\u5358\u9805 + \u306E\u76F4\u5F8C\u306B\u306F\u6570\u5024\u30EA\u30C6\u30E9\u30EB\u304C\u5FC5\u8981\u3067\u3059");
|
|
3318
|
+
return makeNumberLiteral(`+${number.value}`);
|
|
3319
|
+
}
|
|
3315
3320
|
if (this.allowRelativeDateFunctions && tok.kind === "IDENT" /* IDENT */ && this.peekAt(1).kind === "(" /* LPAREN */ && isRelativeDateFunctionName(tok.value.toUpperCase())) {
|
|
3316
3321
|
return this.parseRelativeDateFunction();
|
|
3317
3322
|
}
|
|
@@ -12330,7 +12335,8 @@ var NATIVE_OPERATORS = /* @__PURE__ */ new Map([
|
|
|
12330
12335
|
["USER_SELECT", /* @__PURE__ */ new Set(["in", "not in"])],
|
|
12331
12336
|
["ORGANIZATION_SELECT", /* @__PURE__ */ new Set(["in", "not in"])],
|
|
12332
12337
|
["GROUP_SELECT", /* @__PURE__ */ new Set(["in", "not in"])],
|
|
12333
|
-
["STATUS", new Set(EQUALITY_IN)]
|
|
12338
|
+
["STATUS", new Set(EQUALITY_IN)],
|
|
12339
|
+
["STATUS_ASSIGNEE", /* @__PURE__ */ new Set(["in", "not in"])]
|
|
12334
12340
|
]);
|
|
12335
12341
|
var LOCAL_VALID_OPERATORS = /* @__PURE__ */ new Map([
|
|
12336
12342
|
["CREATOR", /* @__PURE__ */ new Set(["in", "not in"])],
|
|
@@ -12784,6 +12790,44 @@ function requireExactFunctionPushdown(result) {
|
|
|
12784
12790
|
);
|
|
12785
12791
|
}
|
|
12786
12792
|
|
|
12793
|
+
// src/core/optimization/joinDateTimeLiteralPolicy.ts
|
|
12794
|
+
function isCanonicalJoinDate(value) {
|
|
12795
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
12796
|
+
if (!match) return false;
|
|
12797
|
+
const year = Number(match[1]);
|
|
12798
|
+
const month = Number(match[2]);
|
|
12799
|
+
const day = Number(match[3]);
|
|
12800
|
+
if (year < 1 || year > 9999) return false;
|
|
12801
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
12802
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
12803
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
12804
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
12805
|
+
}
|
|
12806
|
+
function isCanonicalJoinTime(value) {
|
|
12807
|
+
const match = /^(\d{2}):(\d{2})$/.exec(value);
|
|
12808
|
+
return match !== null && Number(match[1]) <= 23 && Number(match[2]) <= 59;
|
|
12809
|
+
}
|
|
12810
|
+
function isCanonicalJoinDateTime(value) {
|
|
12811
|
+
const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/.exec(value);
|
|
12812
|
+
if (!match || !isCanonicalJoinDate(match[1])) return false;
|
|
12813
|
+
return Number(match[2]) <= 23 && Number(match[3]) <= 59 && Number(match[4]) <= 59;
|
|
12814
|
+
}
|
|
12815
|
+
|
|
12816
|
+
// src/core/optimization/joinNumberLiteralPolicy.ts
|
|
12817
|
+
function isJoinNumberLiteralSupported(literal) {
|
|
12818
|
+
const source = literal.raw ?? String(literal.value);
|
|
12819
|
+
const decimal = parseExactDecimal(source);
|
|
12820
|
+
if (decimal === null) return false;
|
|
12821
|
+
if (decimal.sign === 0) return numberLiteralText(literal) === "0";
|
|
12822
|
+
const fractionDigits = Math.max(decimal.scale, 0);
|
|
12823
|
+
const integerDigits = Math.max(decimal.coefficient.length - decimal.scale, 0);
|
|
12824
|
+
if (fractionDigits > 10 || integerDigits + fractionDigits > 30) {
|
|
12825
|
+
return false;
|
|
12826
|
+
}
|
|
12827
|
+
const canonical = formatPlainDecimal(decimal);
|
|
12828
|
+
return numberLiteralText(literal) === canonical;
|
|
12829
|
+
}
|
|
12830
|
+
|
|
12787
12831
|
// src/core/optimization/joinPredicatePushdown.ts
|
|
12788
12832
|
var SELECTION_TYPES = /* @__PURE__ */ new Set([
|
|
12789
12833
|
"DROP_DOWN",
|
|
@@ -12792,6 +12836,14 @@ var SELECTION_TYPES = /* @__PURE__ */ new Set([
|
|
|
12792
12836
|
"MULTI_SELECT",
|
|
12793
12837
|
"STATUS"
|
|
12794
12838
|
]);
|
|
12839
|
+
var USER_CODE_TYPES = /* @__PURE__ */ new Set([
|
|
12840
|
+
"CREATOR",
|
|
12841
|
+
"MODIFIER",
|
|
12842
|
+
"USER_SELECT",
|
|
12843
|
+
"ORGANIZATION_SELECT",
|
|
12844
|
+
"GROUP_SELECT",
|
|
12845
|
+
"STATUS_ASSIGNEE"
|
|
12846
|
+
]);
|
|
12795
12847
|
var KLIKE_TYPES = /* @__PURE__ */ new Set([
|
|
12796
12848
|
"SINGLE_LINE_TEXT",
|
|
12797
12849
|
"LINK",
|
|
@@ -12799,7 +12851,7 @@ var KLIKE_TYPES = /* @__PURE__ */ new Set([
|
|
|
12799
12851
|
"RICH_TEXT",
|
|
12800
12852
|
"FILE"
|
|
12801
12853
|
]);
|
|
12802
|
-
var
|
|
12854
|
+
var DATETIME_TYPES = /* @__PURE__ */ new Set([
|
|
12803
12855
|
"DATETIME",
|
|
12804
12856
|
"CREATED_TIME",
|
|
12805
12857
|
"UPDATED_TIME"
|
|
@@ -13395,21 +13447,45 @@ function classifySupportedLeaf(predicate, owner, fieldType) {
|
|
|
13395
13447
|
return isPositiveSafeInteger(predicate.right) && (predicate.op === "=" || predicate.op === "<" || predicate.op === ">" || predicate.op === "<=" || predicate.op === ">=") ? "exact" : "unsafe";
|
|
13396
13448
|
}
|
|
13397
13449
|
if (fieldType === "RECORD_NUMBER") {
|
|
13398
|
-
return
|
|
13450
|
+
return classifySupersetScalarOrListLiteral(predicate);
|
|
13399
13451
|
}
|
|
13400
13452
|
if (fieldType === "NUMBER") {
|
|
13401
|
-
if (predicate.
|
|
13402
|
-
|
|
13403
|
-
|
|
13453
|
+
if ((predicate.op === "IN" || predicate.op === "NOT_IN") && predicate.right.type === "IN_LIST" && predicate.right.values.length > 0 && predicate.right.values.every(
|
|
13454
|
+
(value) => value.type === "NUMBER" && isJoinNumberLiteralSupported(value)
|
|
13455
|
+
)) {
|
|
13456
|
+
return "exact";
|
|
13457
|
+
}
|
|
13458
|
+
if ((predicate.op === "=" || predicate.op === "!=" || predicate.op === "<>" || predicate.op === "<" || predicate.op === ">" || predicate.op === "<=" || predicate.op === ">=") && predicate.right.type === "NUMBER" && isJoinNumberLiteralSupported(predicate.right)) {
|
|
13459
|
+
return "exact";
|
|
13460
|
+
}
|
|
13461
|
+
return "unsafe";
|
|
13404
13462
|
}
|
|
13405
|
-
if (fieldType === "
|
|
13406
|
-
return predicate
|
|
13463
|
+
if (fieldType === "CALC") {
|
|
13464
|
+
return classifySupersetScalarOrListLiteral(predicate);
|
|
13407
13465
|
}
|
|
13408
|
-
if (
|
|
13409
|
-
if (predicate.op !== "
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13466
|
+
if (USER_CODE_TYPES.has(fieldType)) {
|
|
13467
|
+
if (predicate.op !== "IN" && predicate.op !== "NOT_IN" || predicate.right.type !== "IN_LIST" || predicate.right.values.length === 0) return "unsafe";
|
|
13468
|
+
return predicate.right.values.every(
|
|
13469
|
+
(value) => value.type === "STRING" && value.value !== ""
|
|
13470
|
+
) ? "exact" : "unsafe";
|
|
13471
|
+
}
|
|
13472
|
+
if (fieldType === "SINGLE_LINE_TEXT" || fieldType === "LINK") {
|
|
13473
|
+
if ((predicate.op === "IN" || predicate.op === "NOT_IN") && predicate.right.type === "IN_LIST" && predicate.right.values.length > 0 && predicate.right.values.every(
|
|
13474
|
+
(value) => value.type === "STRING" && value.value !== ""
|
|
13475
|
+
)) {
|
|
13476
|
+
return "exact";
|
|
13477
|
+
}
|
|
13478
|
+
return (predicate.op === "=" || predicate.op === "!=" || predicate.op === "<>") && predicate.right.type === "STRING" && predicate.right.value !== "" ? "exact" : "unsafe";
|
|
13479
|
+
}
|
|
13480
|
+
if (fieldType === "DATE" || fieldType === "TIME" || DATETIME_TYPES.has(fieldType)) {
|
|
13481
|
+
if (predicate.op !== "=" && predicate.op !== "!=" && predicate.op !== "<>" && predicate.op !== "<" && predicate.op !== ">" && predicate.op !== "<=" && predicate.op !== ">=" || predicate.right.type !== "STRING") return "unsafe";
|
|
13482
|
+
if (fieldType === "DATE") {
|
|
13483
|
+
return isCanonicalJoinDate(predicate.right.value) ? "exact" : "unsafe";
|
|
13484
|
+
}
|
|
13485
|
+
if (fieldType === "TIME") {
|
|
13486
|
+
return isCanonicalJoinTime(predicate.right.value) ? "exact" : "unsafe";
|
|
13487
|
+
}
|
|
13488
|
+
return isCanonicalJoinDateTime(predicate.right.value) ? "exact" : "unsafe";
|
|
13413
13489
|
}
|
|
13414
13490
|
if (SELECTION_TYPES.has(fieldType)) {
|
|
13415
13491
|
if (predicate.op !== "IN" && predicate.op !== "NOT_IN" || predicate.right.type !== "IN_LIST" || predicate.right.values.length === 0) return "unsafe";
|
|
@@ -13421,6 +13497,19 @@ function classifySupportedLeaf(predicate, owner, fieldType) {
|
|
|
13421
13497
|
}
|
|
13422
13498
|
return "unsafe";
|
|
13423
13499
|
}
|
|
13500
|
+
function classifySupersetScalarOrListLiteral(predicate) {
|
|
13501
|
+
const supportedLiteral = (value) => value.type === "NUMBER" && isJoinNumberLiteralSupported(value) || value.type === "STRING" && value.value !== "";
|
|
13502
|
+
if ((predicate.op === "IN" || predicate.op === "NOT_IN") && predicate.right.type === "IN_LIST") {
|
|
13503
|
+
const values = predicate.right.values;
|
|
13504
|
+
if (values.length > 0 && values.every(supportedLiteral) && values.every((value) => value.type === values[0].type)) {
|
|
13505
|
+
return "superset";
|
|
13506
|
+
}
|
|
13507
|
+
}
|
|
13508
|
+
if ((predicate.op === "=" || predicate.op === "!=" || predicate.op === "<>" || predicate.op === "<" || predicate.op === ">" || predicate.op === "<=" || predicate.op === ">=") && supportedLiteral(predicate.right)) {
|
|
13509
|
+
return "superset";
|
|
13510
|
+
}
|
|
13511
|
+
return "unsafe";
|
|
13512
|
+
}
|
|
13424
13513
|
function owned(source, fieldCode) {
|
|
13425
13514
|
return Object.freeze({
|
|
13426
13515
|
status: "OWNED",
|
|
@@ -13445,24 +13534,6 @@ function isPositiveSafeInteger(value) {
|
|
|
13445
13534
|
function isSafeIntegerLiteral(value) {
|
|
13446
13535
|
return /^-?\d+$/.test(numberLiteralText(value)) && Number.isSafeInteger(value.value);
|
|
13447
13536
|
}
|
|
13448
|
-
function isCanonicalDate(value) {
|
|
13449
|
-
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
13450
|
-
if (!match) return false;
|
|
13451
|
-
const year = Number(match[1]);
|
|
13452
|
-
const month = Number(match[2]);
|
|
13453
|
-
const day = Number(match[3]);
|
|
13454
|
-
const date = new Date(Date.UTC(year, month - 1, day));
|
|
13455
|
-
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
13456
|
-
}
|
|
13457
|
-
function isCanonicalTime(value) {
|
|
13458
|
-
const match = /^(\d{2}):(\d{2})$/.exec(value);
|
|
13459
|
-
return match !== null && Number(match[1]) <= 23 && Number(match[2]) <= 59;
|
|
13460
|
-
}
|
|
13461
|
-
function isCanonicalDateTime(value) {
|
|
13462
|
-
const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/.exec(value);
|
|
13463
|
-
if (!match || !isCanonicalDate(match[1])) return false;
|
|
13464
|
-
return Number(match[2]) <= 23 && Number(match[3]) <= 59 && Number(match[4]) <= 59;
|
|
13465
|
-
}
|
|
13466
13537
|
function collectKlikes2(where, out) {
|
|
13467
13538
|
if (where === null) return;
|
|
13468
13539
|
if (isKlike(where)) {
|