From 24669481d1a35dfac555edea4e60cfc7fa23bbfa Mon Sep 17 00:00:00 2001 From: Scott Trinh Date: Wed, 17 Jan 2024 10:09:35 -0500 Subject: [PATCH] Move UUID->Object cast test into LTS --- integration-tests/lts/casts.test.ts | 17 ++++++ .../stable/uuid-to-object-cast.test.ts | 57 ------------------- 2 files changed, 17 insertions(+), 57 deletions(-) delete mode 100644 integration-tests/stable/uuid-to-object-cast.test.ts diff --git a/integration-tests/lts/casts.test.ts b/integration-tests/lts/casts.test.ts index 562e5bb55..94b330848 100644 --- a/integration-tests/lts/casts.test.ts +++ b/integration-tests/lts/casts.test.ts @@ -48,4 +48,21 @@ describe("casts", () => { tc.assert>(true); }); + + test("UUID to object cast", () => { + const expr = e.cast( + e.Movie, + e.cast(e.uuid, "00000000-0000-0000-0000-000000000000") + ); + + assert.equal( + expr.toEdgeQL(), + `(("00000000-0000-0000-0000-000000000000"))` + ); + + tc.assert>(true); + + // @ts-expect-error: does not allow assignment of non UUID + e.cast(e.Movie, 42); + }); }); diff --git a/integration-tests/stable/uuid-to-object-cast.test.ts b/integration-tests/stable/uuid-to-object-cast.test.ts deleted file mode 100644 index c339dd291..000000000 --- a/integration-tests/stable/uuid-to-object-cast.test.ts +++ /dev/null @@ -1,57 +0,0 @@ -import assert from "node:assert/strict"; -import { type Client } from "edgedb"; -import e, { type $infer } from "./dbschema/edgeql-js"; -import { setupTests, tc, teardownTests } from "./setupTeardown"; - -describe("pgvector", () => { - let client: Client; - beforeAll(async () => { - const setup = await setupTests(); - ({ client } = setup); - }); - - afterAll(async () => { - await teardownTests(client); - }, 10_000); - - test("test casting UUID to object", async () => { - const vec1234 = Float32Array.from( - Array.from({ length: 1234 }).fill(0) as number[] - ); - const inserted = await e - .insert(e.PgVectorTest, { - test_embedding: e.ext.pgvector.vector(vec1234), - }) - .run(client); - - const castToObject = e.select(e.PgVectorTest, () => ({ - internal: e.cast(e.PgVectorTest, e.cast(e.uuid, inserted.id)), - })); - - tc.assert< - tc.IsExact< - $infer, - { - internal: { - id: string; - }; - }[] - > - >(true); - - assert.equal( - castToObject.toEdgeQL(), - `\ -WITH - __scope_0_defaultPgVectorTest := DETACHED default::PgVectorTest -SELECT __scope_0_defaultPgVectorTest { - single internal := (("${inserted.id}")) -}` - ); - - e.select(e.PgVectorTest, () => ({ - // @ts-expect-error: does not allow assignment of non UUID - internal: e.cast(e.PgVectorTest, inserted.id), - })); - }); -});