mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-11 07:51:20 +00:00
Merge branch '290-fix-bug-where-single-select-field-without-options-can-t-be-converted-to-a-text-field' into 'develop'
Draft: Resolve "Fix bug where single select field without options can't be converted to a text field" Closes #290 See merge request bramw/baserow!158
This commit is contained in:
commit
058d70a419
3 changed files with 12 additions and 1 deletions
|
@ -802,6 +802,11 @@ class SingleSelectFieldType(FieldType):
|
|||
variables[variable_name] = option.value
|
||||
values_mapping.append(f"('{int(option.id)}', %({variable_name})s)")
|
||||
|
||||
# If there are no values we don't need to convert the value to a string
|
||||
# since all values will be converted to null.
|
||||
if len(values_mapping) == 0:
|
||||
return None
|
||||
|
||||
sql = f"""
|
||||
p_in = (SELECT value FROM (
|
||||
VALUES {','.join(values_mapping)}
|
||||
|
@ -829,7 +834,7 @@ class SingleSelectFieldType(FieldType):
|
|||
f"(lower(%({variable_name})s), '{int(option.id)}')"
|
||||
)
|
||||
|
||||
# If there is no values we don't need to convert the value since all
|
||||
# If there are no values we don't need to convert the value since all
|
||||
# values should be converted to null.
|
||||
if len(values_mapping) == 0:
|
||||
return None
|
||||
|
|
|
@ -58,6 +58,10 @@ def test_single_select_field_type(data_fixture):
|
|||
field_handler.delete_field(user=user, field=field)
|
||||
assert SelectOption.objects.all().count() == 0
|
||||
|
||||
field = field_handler.create_field(user=user, table=table,
|
||||
type_name='single_select', select_options=[])
|
||||
field_handler.update_field(user=user, field=field, new_type_name='text')
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_single_select_field_type_rows(data_fixture, django_assert_num_queries):
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* Fixed the "Ignored attempt to cancel a touchmove" error.
|
||||
* Refactored the has_user everywhere such that the raise_error argument is used when
|
||||
possible.
|
||||
* Fixed bug where a single select field without options could not be converted to a
|
||||
another field.
|
||||
|
||||
## Released (2021-02-04)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue