Get previous adjacent row doesn't work without view specified
Describe the problem
When running RowHandler.get_adjacent_row
with previous=True
and no view
specified, the function will always return the first row in the table.
Steps to reproduce
Add this test to your test_rows_handler.py
and see the last assert
failing.
@pytest.mark.django_db
def test_get_adjacent_row_no_view(data_fixture):
user = data_fixture.create_user()
table = data_fixture.create_database_table(user=user)
name_field = data_fixture.create_text_field(
table=table, name="Name", text_default="Test"
)
handler = RowHandler()
[row_1, row_2, row_3, row_4, row_5, row_6] = handler.create_rows(
user=user,
table=table,
rows_values=[
{
f"field_{name_field.id}": "A",
},
{
f"field_{name_field.id}": "B",
},
{
f"field_{name_field.id}": "C",
},
{
f"field_{name_field.id}": "D",
},
{
f"field_{name_field.id}": "E",
},
{
f"field_{name_field.id}": "F",
},
],
)
base_queryset = table.get_model().objects.all()
assert handler.get_adjacent_row(row_4, base_queryset).id == row_5.id
assert handler.get_adjacent_row(row_4, base_queryset, previous=True).id == row_3.id
Actual result
It will return the first row of the table.
Expected result
It should return the previous row of the row specified.
Environment
- Operating System: Windows/Ubuntu/Mac/etc.
- Web Browser: Chrome / Firefox / Edge / Safari
- Deployment Type: baserow.io / docker / cloudron / ubuntu with supervisor / heroku / other
- Baserow Version: Develop / 1.8 / 1.7 / 1.6 etc