-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unique indexes and indexes for composite types #7162
Changes from all commits
05c3ff1
b668d45
3d5e149
4e79c01
5d265fb
3255104
3fdffce
3b7d6cd
5cfa045
d125250
33bfe5c
fede32a
e03888e
43727a3
58522fb
42d0dcd
a740bc3
2b7e2b3
5605c00
4d4a368
fb2c6a4
b4f1b5a
6c147f9
8d33bbb
6573253
f80414a
8f4471e
5540edb
ef7ecfc
d84812f
1d3a5a7
794e0d6
6920a70
9beeaf6
3410bf9
3f54928
886a7e9
75ce755
a7ba38e
d537979
cbb1eeb
77b719c
249da24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { findAvailableTimeZoneOption } from '@/localization/utils/findAvailableTimeZoneOption'; | ||
|
||
describe('findAvailableTimeZoneOption', () => { | ||
it('should find the matching available IANA time zone select option from a given IANA time zone', () => { | ||
const ianaTimeZone = 'Europe/Paris'; | ||
const expectedOption = { | ||
label: '(GMT+02:00) Central European Summer Time - Paris', | ||
value: 'Europe/Paris', | ||
}; | ||
|
||
const option = findAvailableTimeZoneOption(ianaTimeZone); | ||
|
||
expect(option).toEqual(expectedOption); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,24 +6,11 @@ import { currentUserState } from '@/auth/states/currentUserState'; | |
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState'; | ||
import { useFindManyObjectMetadataItems } from '@/object-metadata/hooks/useFindManyObjectMetadataItems'; | ||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState'; | ||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem'; | ||
import { FieldMetadataType } from '~/generated-metadata/graphql'; | ||
import { WorkspaceActivationStatus } from '~/generated/graphql'; | ||
import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems'; | ||
import { isDeeplyEqual } from '~/utils/isDeeplyEqual'; | ||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull'; | ||
|
||
const filterTsVectorFields = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we want to keep that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see it seems you handled it differently 👍 |
||
objectMetadataItems: ObjectMetadataItem[], | ||
): ObjectMetadataItem[] => { | ||
return objectMetadataItems.map((item) => ({ | ||
...item, | ||
fields: item.fields.filter( | ||
(field) => field.type !== FieldMetadataType.TsVector, | ||
), | ||
})); | ||
}; | ||
|
||
export const ObjectMetadataItemsLoadEffect = () => { | ||
const currentUser = useRecoilValue(currentUserState); | ||
const currentWorkspace = useRecoilValue(currentWorkspaceState); | ||
|
@@ -37,13 +24,12 @@ export const ObjectMetadataItemsLoadEffect = () => { | |
const updateObjectMetadataItems = useRecoilCallback( | ||
({ set, snapshot }) => | ||
() => { | ||
const filteredFields = filterTsVectorFields(newObjectMetadataItems); | ||
const toSetObjectMetadataItems = | ||
isUndefinedOrNull(currentUser) || | ||
currentWorkspace?.activationStatus !== | ||
WorkspaceActivationStatus.Active | ||
? generatedMockObjectMetadataItems | ||
: filteredFields; | ||
: newObjectMetadataItems; | ||
|
||
if ( | ||
!isDeeplyEqual( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { useMemo } from 'react'; | ||
import { useQuery } from '@apollo/client'; | ||
import { useMemo } from 'react'; | ||
|
||
Comment on lines
1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Import order changed. Consider using a consistent import order throughout the codebase. |
||
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar'; | ||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; | ||
|
@@ -41,12 +41,9 @@ export const useFindManyObjectMetadataItems = ({ | |
skip: skip || !apolloMetadataClient, | ||
onError: (error) => { | ||
logError('useFindManyObjectMetadataItems error : ' + error); | ||
enqueueSnackBar( | ||
`Error during useFindManyObjectMetadataItems, ${error.message}`, | ||
{ | ||
variant: SnackBarVariant.Error, | ||
}, | ||
); | ||
enqueueSnackBar(`${error.message}`, { | ||
variant: SnackBarVariant.Error, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was too dev-oriented |
||
}); | ||
}, | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { IndexField as GeneratedIndexField } from '~/generated-metadata/graphql'; | ||
|
||
export type IndexFieldMetadataItem = Omit<GeneratedIndexField, '__typename'> & { | ||
__typename?: string; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { IndexFieldMetadataItem } from '@/object-metadata/types/IndexFieldMetadataItem'; | ||
import { Index as GeneratedIndex } from '~/generated-metadata/graphql'; | ||
|
||
export type IndexMetadataItem = Omit< | ||
GeneratedIndex, | ||
'__typename' | 'indexFieldMetadatas' | 'objectMetadata' | ||
> & { | ||
__typename?: string; | ||
indexFieldMetadatas: IndexFieldMetadataItem[]; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { Object as GeneratedObject } from '~/generated-metadata/graphql'; | ||
|
||
import { IndexMetadataItem } from '@/object-metadata/types/IndexMetadataItem'; | ||
import { FieldMetadataItem } from './FieldMetadataItem'; | ||
|
||
export type ObjectMetadataItem = Omit< | ||
GeneratedObject, | ||
'__typename' | 'fields' | 'dataSourceId' | ||
'__typename' | 'fields' | 'dataSourceId' | 'indexMetadatas' | ||
> & { | ||
__typename?: string; | ||
fields: FieldMetadataItem[]; | ||
indexMetadatas: IndexMetadataItem[]; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { z } from 'zod'; | ||
|
||
import { IndexFieldMetadataItem } from '@/object-metadata/types/IndexFieldMetadataItem'; | ||
|
||
export const indexFieldMetadataItemSchema = z.object({ | ||
__typename: z.literal('indexField'), | ||
fieldMetadataId: z.string().uuid(), | ||
id: z.string(), | ||
createdAt: z.string(), | ||
updatedAt: z.string(), | ||
order: z.number(), | ||
}) satisfies z.ZodType<IndexFieldMetadataItem>; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { z } from 'zod'; | ||
|
||
import { IndexMetadataItem } from '@/object-metadata/types/IndexMetadataItem'; | ||
import { indexFieldMetadataItemSchema } from '@/object-metadata/validation-schemas/indexFieldMetadataItemSchema'; | ||
import { IndexType } from '~/generated-metadata/graphql'; | ||
|
||
export const indexMetadataItemSchema = z.object({ | ||
__typename: z.literal('index'), | ||
id: z.string().uuid(), | ||
name: z.string(), | ||
indexFieldMetadatas: z.array(indexFieldMetadataItemSchema), | ||
createdAt: z.string(), | ||
updatedAt: z.string(), | ||
indexType: z.nativeEnum(IndexType), | ||
indexWhereClause: z.string().nullable(), | ||
isUnique: z.boolean(), | ||
objectMetadata: z.any(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: objectMetadata: z.any() is too permissive. Define a more specific schema |
||
}) satisfies z.ZodType<IndexMetadataItem>; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,12 +53,9 @@ export const useFindDuplicateRecords = <T extends ObjectRecord = ObjectRecord>({ | |
`useFindDuplicateRecords for "${objectMetadataItem.nameSingular}" error : ` + | ||
error, | ||
); | ||
enqueueSnackBar( | ||
`Error during useFindDuplicateRecords for "${objectMetadataItem.nameSingular}", ${error.message}`, | ||
{ | ||
variant: SnackBarVariant.Error, | ||
}, | ||
); | ||
enqueueSnackBar(`Error finding duplicates:", ${error.message}`, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was too dev-oriented |
||
variant: SnackBarVariant.Error, | ||
}); | ||
Comment on lines
+56
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Error message simplified, but consider including the object name for context |
||
}, | ||
}, | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,9 @@ export const useHandleFindManyRecordsError = ({ | |
`useFindManyRecords for "${objectMetadataItem.namePlural}" error : ` + | ||
error, | ||
); | ||
enqueueSnackBar( | ||
`Error during useFindManyRecords for "${objectMetadataItem.namePlural}", ${error.message}`, | ||
{ | ||
variant: SnackBarVariant.Error, | ||
}, | ||
); | ||
enqueueSnackBar(`${error.message}`, { | ||
variant: SnackBarVariant.Error, | ||
}); | ||
Comment on lines
+22
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Consider adding a generic prefix to error messages for consistency |
||
handleError?.(error); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
red color and message usually already convey the fact that it's an error, and there's limited space