@xata.io/drizzle 0.0.0-alpha.vbb2f12358f020e051a1c8f430605b67f373c11d8 → 0.0.0-alpha.vbb7ec16867bbf82e98f0f90d72795a594697d706

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.
@@ -1,6 +1,6 @@
1
1
  import { BaseClient, HostProvider, parseProviderString, XataApiClient } from '@xata.io/client';
2
2
  import 'dotenv/config';
3
- import { desc, DrizzleError, eq, gt, gte, or, placeholder, sql, TransactionRollbackError } from 'drizzle-orm';
3
+ import { desc, DrizzleError, eq, gt, gte, or, placeholder, sql } from 'drizzle-orm';
4
4
  import { Client } from 'pg';
5
5
  import { afterAll, afterEach, beforeAll, beforeEach, describe, expectTypeOf, test } from 'vitest';
6
6
  import { drizzle as drizzlePg, type XataDatabase } from '../src/pg';
@@ -9,7 +9,7 @@ import * as schema from './schema';
9
9
 
10
10
  const { usersTable, postsTable, commentsTable, usersToGroupsTable, groupsTable } = schema;
11
11
 
12
- const ENABLE_LOGGING = true;
12
+ const ENABLE_LOGGING = false;
13
13
 
14
14
  declare module 'vitest' {
15
15
  export interface TestContext {
@@ -891,133 +891,6 @@ describe.concurrent.each([{ type: 'pg' }, { type: 'http' }])('Drizzle $type', ({
891
891
  });
892
892
  });
893
893
 
894
- test('[Find Many] Get users with posts in transaction', async (ctx) => {
895
- let usersWithPosts: {
896
- id: number;
897
- name: string;
898
- verified: boolean;
899
- invitedBy: number | null;
900
- posts: {
901
- id: number;
902
- content: string;
903
- ownerId: number | null;
904
- createdAt: Date;
905
- }[];
906
- }[] = [];
907
-
908
- await ctx.db.transaction(async (tx) => {
909
- await tx.insert(usersTable).values([
910
- { id: 1, name: 'Dan' },
911
- { id: 2, name: 'Andrew' },
912
- { id: 3, name: 'Alex' }
913
- ]);
914
-
915
- await tx.insert(postsTable).values([
916
- { ownerId: 1, content: 'Post1' },
917
- { ownerId: 1, content: 'Post1.1' },
918
- { ownerId: 2, content: 'Post2' },
919
- { ownerId: 3, content: 'Post3' }
920
- ]);
921
-
922
- usersWithPosts = await tx.query.usersTable.findMany({
923
- where: ({ id }, { eq }) => eq(id, 1),
924
- with: {
925
- posts: {
926
- where: ({ id }, { eq }) => eq(id, 1)
927
- }
928
- }
929
- });
930
- });
931
-
932
- expectTypeOf(usersWithPosts).toEqualTypeOf<
933
- {
934
- id: number;
935
- name: string;
936
- verified: boolean;
937
- invitedBy: number | null;
938
- posts: {
939
- id: number;
940
- content: string;
941
- ownerId: number | null;
942
- createdAt: Date;
943
- }[];
944
- }[]
945
- >();
946
-
947
- ctx.expect(usersWithPosts.length).eq(1);
948
- ctx.expect(usersWithPosts[0]?.posts.length).eq(1);
949
-
950
- ctx.expect(usersWithPosts[0]).toEqual({
951
- id: 1,
952
- name: 'Dan',
953
- verified: false,
954
- invitedBy: null,
955
- posts: [{ id: 1, ownerId: 1, content: 'Post1', createdAt: usersWithPosts[0]?.posts[0]?.createdAt }]
956
- });
957
- });
958
-
959
- test('[Find Many] Get users with posts in rollbacked transaction', async (ctx) => {
960
- let usersWithPosts: {
961
- id: number;
962
- name: string;
963
- verified: boolean;
964
- invitedBy: number | null;
965
- posts: {
966
- id: number;
967
- content: string;
968
- ownerId: number | null;
969
- createdAt: Date;
970
- }[];
971
- }[] = [];
972
-
973
- await ctx
974
- .expect(
975
- ctx.db.transaction(async (tx) => {
976
- await tx.insert(usersTable).values([
977
- { id: 1, name: 'Dan' },
978
- { id: 2, name: 'Andrew' },
979
- { id: 3, name: 'Alex' }
980
- ]);
981
-
982
- await tx.insert(postsTable).values([
983
- { ownerId: 1, content: 'Post1' },
984
- { ownerId: 1, content: 'Post1.1' },
985
- { ownerId: 2, content: 'Post2' },
986
- { ownerId: 3, content: 'Post3' }
987
- ]);
988
-
989
- tx.rollback();
990
-
991
- usersWithPosts = await tx.query.usersTable.findMany({
992
- where: ({ id }, { eq }) => eq(id, 1),
993
- with: {
994
- posts: {
995
- where: ({ id }, { eq }) => eq(id, 1)
996
- }
997
- }
998
- });
999
- })
1000
- )
1001
- .rejects.toThrowError(new TransactionRollbackError());
1002
-
1003
- expectTypeOf(usersWithPosts).toEqualTypeOf<
1004
- {
1005
- id: number;
1006
- name: string;
1007
- verified: boolean;
1008
- invitedBy: number | null;
1009
- posts: {
1010
- id: number;
1011
- content: string;
1012
- ownerId: number | null;
1013
- createdAt: Date;
1014
- }[];
1015
- }[]
1016
- >();
1017
-
1018
- ctx.expect(usersWithPosts.length).eq(0);
1019
- });
1020
-
1021
894
  // select only custom
1022
895
  test('[Find Many] Get only custom fields', async (ctx) => {
1023
896
  await ctx.db.insert(usersTable).values([