1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-11 07:51:20 +00:00

Merge branch '2473-ensure-that-the-get-row-service-type-path-importer-receives-no-field-it-doesn-t-fail-hard' into 'develop'

Resolve "Ensure that the get row service type path importer receives no field, it doesn't fail hard."

Closes 

See merge request 
This commit is contained in:
Peter Evans 2024-03-27 15:40:35 +00:00
commit ff21d31f5f
3 changed files with 51 additions and 1 deletions
backend
src/baserow/contrib/integrations/local_baserow
tests/baserow/contrib/integrations/local_baserow
changelog/entries/unreleased/bug

View file

@ -810,7 +810,14 @@ class LocalBaserowGetRowUserServiceType(
Updates the field ids in the path.
"""
field_dbname, *rest = path
# If the path length is greater or equal to one, then we have
# the GetRow data source formula format of `data_source.PK.field`.
if len(path) >= 1:
field_dbname, *rest = path
else:
# In any other scenario, we have a formula that is not a format we
# can currently import properly, so we return the path as is.
return path
if field_dbname == "id":
return path

View file

@ -2332,3 +2332,39 @@ def test_import_datasource_provider_formula_using_list_rows_service_containing_n
duplicated_element.specific.placeholder
== f"get('data_source.{duplicated_data_source.id}')"
)
@pytest.mark.django_db
def test_import_datasource_provider_formula_using_get_row_service_containing_no_field_fails_silently(
data_fixture,
):
user = data_fixture.create_user()
workspace = data_fixture.create_workspace(user=user)
builder = data_fixture.create_builder_application(workspace=workspace)
database = data_fixture.create_database_application(workspace=workspace)
integration = data_fixture.create_local_baserow_integration(
application=builder, authorized_user=user
)
table = data_fixture.create_database_table(database=database)
page = data_fixture.create_builder_page(builder=builder)
service = data_fixture.create_local_baserow_get_row_service(
integration=integration,
table=table,
)
data_source = DataSourceService().create_data_source(
user, service_type=service.get_type(), page=page
)
ElementService().create_element(
user,
element_type_registry.get("input_text"),
page=page,
data_source_id=data_source.id,
placeholder=f"get('data_source.{data_source.id}')",
)
duplicated_page = PageService().duplicate_page(user, page)
duplicated_element = duplicated_page.element_set.first()
duplicated_data_source = duplicated_page.datasource_set.first()
assert (
duplicated_element.specific.placeholder
== f"get('data_source.{duplicated_data_source.id}')"
)

View file

@ -0,0 +1,7 @@
{
"type": "bug",
"message": "ensure that the get row service type path importer receives no field it doesn t fail hard",
"issue_number": 2473,
"bullet_points": [],
"created_at": "2024-03-27"
}