diff --git a/client/components/Editors/Schema/Sections/Fields.tsx b/client/components/Editors/Schema/Sections/Fields.tsx index 693341442..4f3d16ab9 100644 --- a/client/components/Editors/Schema/Sections/Fields.tsx +++ b/client/components/Editors/Schema/Sections/Fields.tsx @@ -432,12 +432,16 @@ function Required() { const updateField = useStore((state) => state.updateField) const constraints = useStore(select(selectors.field, (field) => field.constraints)) const updateHelp = useStore((state) => state.updateHelp) + return ( updateHelp('schema/fields/required')} value={constraints?.required || false} - onChange={(required) => updateField({ constraints: { ...constraints, required } })} + onChange={(value) => { + const required = value || undefined + updateField({ constraints: { ...constraints, required } }) + }} /> ) } @@ -611,12 +615,14 @@ function MinimumNumber() { const constraints = useStore(select(selectors.field, (field) => field.constraints)) const updateHelp = useStore((state) => state.updateHelp) const [isValid, setIsValid] = React.useState(isValidMinimumNumber()) + function isValidMinimumNumber() { if (!constraints) return true return constraints.minimum ? validator.isNumeric(constraints.minimum.toString()) : true } + return ( { setIsValid(isValidMinimumNumber()) }} - onChange={(value) => - updateField({ constraints: { ...constraints, minimum: parseInt(value) } }) - } + onChange={(value) => { + const minimum = value || undefined + updateField({ constraints: { ...constraints, minimum } }) + }} helperText={!isValid ? 'Minimum value is not valid.' : ''} /> ) @@ -640,12 +647,14 @@ function MaximumNumber() { const constraints = useStore(select(selectors.field, (field) => field.constraints)) const updateHelp = useStore((state) => state.updateHelp) const [isValid, setIsValid] = React.useState(isValidMaximumNumber()) + function isValidMaximumNumber() { if (!constraints) return true return constraints.maximum ? validator.isNumeric(constraints.maximum.toString()) : true } + return ( { setIsValid(isValidMaximumNumber()) }} - onChange={(value) => - updateField({ constraints: { ...constraints, maximum: parseInt(value) } }) - } + onChange={(value) => { + const maximum = value || undefined + updateField({ constraints: { ...constraints, maximum } }) + }} helperText={!isValid ? 'Maximum value is not valid.' : ''} /> ) @@ -668,15 +678,17 @@ function MinLength() { const updateField = useStore((state) => state.updateField) const constraints = useStore(select(selectors.field, (field) => field.constraints)) const updateHelp = useStore((state) => state.updateHelp) + return ( updateHelp('schema/fields/minLength')} - onChange={(value) => - updateField({ constraints: { ...constraints, minLength: parseInt(value) } }) - } + onChange={(value) => { + const minLength = value ? parseInt(value) : undefined + updateField({ constraints: { ...constraints, minLength } }) + }} /> ) } @@ -685,15 +697,17 @@ function MaxLength() { const updateField = useStore((state) => state.updateField) const constraints = useStore(select(selectors.field, (field) => field.constraints)) const updateHelp = useStore((state) => state.updateHelp) + return ( updateHelp('schema/fields/maxLength')} - onChange={(value) => - updateField({ constraints: { ...constraints, maxLength: parseInt(value) } }) - } + onChange={(value) => { + const maxLength = value ? parseInt(value) : undefined + updateField({ constraints: { ...constraints, maxLength } }) + }} /> ) } @@ -702,13 +716,17 @@ function Pattern() { const updateField = useStore((state) => state.updateField) const constraints = useStore(select(selectors.field, (field) => field.constraints)) const updateHelp = useStore((state) => state.updateHelp) + return ( updateHelp('schema/fields/pattern')} - onChange={(pattern) => updateField({ constraints: { ...constraints, pattern } })} + onChange={(value) => { + const pattern = value || undefined + updateField({ constraints: { ...constraints, pattern } }) + }} /> ) } diff --git a/pyproject.toml b/pyproject.toml index 2c2145f65..4bd2171fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,14 +5,14 @@ requires-python = ">=3.11" dependencies = [ # Core "fastapi==0.103.1", - "frictionless==5.16.0", + "frictionless==5.18.0", "gitignore-parser==0.1.6", "openai==0.28.0", "pydantic==2.3.0", "python-multipart==0.0.6", "sqlalchemy==2.0.20", "tinydb==4.8.0", - "typer==0.9.0", + "typer==0.12.0", "typing_extensions==4.8.0", "uvicorn==0.23.2", # Gsheets diff --git a/server/helpers/resource.py b/server/helpers/resource.py index ba7429fea..ae01d22f9 100644 --- a/server/helpers/resource.py +++ b/server/helpers/resource.py @@ -22,6 +22,7 @@ def index_resource(project: Project, resource: Resource, table_name: str): database=db.engine, table_name=table_name, with_metadata=True, + ignore_constraints=True, ) report = indexer.index()