diff --git a/app/__test__/data/specs/WithBuilder.spec.ts b/app/__test__/data/specs/WithBuilder.spec.ts index 094f9a7..db0273c 100644 --- a/app/__test__/data/specs/WithBuilder.spec.ts +++ b/app/__test__/data/specs/WithBuilder.spec.ts @@ -1,5 +1,4 @@ -import { afterAll, describe, expect, test } from "bun:test"; -import { _jsonp } from "../../../src/core/utils"; +import { describe, expect, test } from "bun:test"; import { Entity, EntityManager, @@ -10,7 +9,7 @@ import { WithBuilder, } from "../../../src/data"; import * as proto from "../../../src/data/prototype"; -import { compileQb, prettyPrintQb, schemaToEm } from "../../helper"; +import { schemaToEm } from "../../helper"; import { getDummyConnection } from "../helper"; const { dummyConnection } = getDummyConnection(); @@ -30,7 +29,7 @@ describe("[data] WithBuilder", async () => { ); const em = schemaToEm(schema); - expect(WithBuilder.validateWiths(em, "posts", undefined)).toBe(0); + expect(WithBuilder.validateWiths(em, "posts", undefined as any)).toBe(0); expect(WithBuilder.validateWiths(em, "posts", {})).toBe(0); expect(WithBuilder.validateWiths(em, "posts", { users: {} })).toBe(1); expect( diff --git a/app/src/core/object/query/query.ts b/app/src/core/object/query/query.ts index d70c211..c432daf 100644 --- a/app/src/core/object/query/query.ts +++ b/app/src/core/object/query/query.ts @@ -1,4 +1,6 @@ -export type Primitive = string | number | boolean; +import type { PrimaryFieldType } from "core"; + +export type Primitive = PrimaryFieldType | string | number | boolean; export function isPrimitive(value: any): value is Primitive { return ["string", "number", "boolean"].includes(typeof value); } @@ -63,7 +65,6 @@ function _convert( expressions: Exps, path: string[] = [], ): FilterQuery { - //console.log("-----------------"); const ExpressionConditionKeys = expressions.map((e) => e.key); const keys = Object.keys($query); const operands = [OperandOr] as const; @@ -132,8 +133,6 @@ function _build( ): ValidationResults { const $query = options.convert ? _convert(_query, expressions) : _query; - //console.log("-----------------", { $query }); - //const keys = Object.keys($query); const result: ValidationResults = { $and: [], $or: [], @@ -150,22 +149,16 @@ function _build( if (!exp.valid(expected)) { throw new Error(`Invalid expected value at "${[...path, $op].join(".")}": ${expected}`); } - //console.log("found exp", { key: exp.key, expected, actual }); return exp.validate(expected, actual, options.exp_ctx); } // check $and - //console.log("$and entries", Object.entries($and)); for (const [key, value] of Object.entries($and)) { - //console.log("$op/$v", Object.entries(value)); for (const [$op, $v] of Object.entries(value)) { const objValue = options.value_is_kv ? key : options.object[key]; - //console.log("--check $and", { key, value, objValue, v_i_kv: options.value_is_kv }); - //console.log("validate", { $op, $v, objValue, key }); result.$and.push(__validate($op, $v, objValue, [key])); result.keys.add(key); } - //console.log("-", { key, value }); } // check $or @@ -173,14 +166,11 @@ function _build( const objValue = options.value_is_kv ? key : options.object[key]; for (const [$op, $v] of Object.entries(value)) { - //console.log("validate", { $op, $v, objValue }); result.$or.push(__validate($op, $v, objValue, [key])); result.keys.add(key); } - //console.log("-", { key, value }); } - //console.log("matches", matches); return result; } diff --git a/app/src/data/entities/query/WhereBuilder.ts b/app/src/data/entities/query/WhereBuilder.ts index acafad5..b206bf7 100644 --- a/app/src/data/entities/query/WhereBuilder.ts +++ b/app/src/data/entities/query/WhereBuilder.ts @@ -2,7 +2,6 @@ import { type BooleanLike, type FilterQuery, type Primitive, - type TExpression, exp, isBooleanLike, isPrimitive,