Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmos62 committed Feb 17, 2022
1 parent 8b6222b commit 9d85b5a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion db/functions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BadDBFunctionFormat(DBFunctionException):
pass


class UnknownDBFunctionId(BadDBFunctionFormat):
class UnknownDBFunctionID(BadDBFunctionFormat):
pass


Expand Down
1 change: 0 additions & 1 deletion db/functions/operations/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def apply_db_function_as_filter(relation, db_function):
return relation


# Irrelevant when column ids are used. Still relevant if just column names were used.
def _assert_that_all_referenced_columns_exist(relation, db_function):
columns_that_exist = _get_columns_that_exist(relation)
referenced_columns = db_function.referenced_columns
Expand Down
4 changes: 2 additions & 2 deletions db/functions/operations/deserialize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from db.functions.base import DBFunction, Literal, ColumnName
from db.functions.known_db_functions import known_db_functions
from db.functions.exceptions import UnknownDBFunctionId, BadDBFunctionFormat
from db.functions.exceptions import UnknownDBFunctionID, BadDBFunctionFormat


def get_db_function_from_ma_function_spec(spec: dict) -> DBFunction:
Expand Down Expand Up @@ -62,7 +62,7 @@ def _get_db_function_subclass_by_id(subclass_id):
for db_function_subclass in known_db_functions:
if db_function_subclass.id == subclass_id:
return db_function_subclass
raise UnknownDBFunctionId(
raise UnknownDBFunctionID(
f"DBFunction subclass with id {subclass_id} not found (or not"
+ "available on this DB)."
)
Expand Down
4 changes: 2 additions & 2 deletions db/tests/functions/operations/test_deserialize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from db.functions.exceptions import UnknownDBFunctionId, BadDBFunctionFormat
from db.functions.exceptions import UnknownDBFunctionID, BadDBFunctionFormat
from db.functions.operations.deserialize import get_db_function_from_ma_function_spec


Expand All @@ -11,7 +11,7 @@
{"literal": ["test"]},
]
},
UnknownDBFunctionId
UnknownDBFunctionID
),
(
{"empty": {"column_name": ["varchar"]}, },
Expand Down
4 changes: 2 additions & 2 deletions mathesar/api/db/viewsets/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sqlalchemy.exc import IntegrityError
from sqlalchemy_filters.exceptions import BadSortFormat, SortFieldNotFound

from db.functions.exceptions import BadDBFunctionFormat, UnknownDBFunctionId, ReferencedColumnsDontExist
from db.functions.exceptions import BadDBFunctionFormat, UnknownDBFunctionID, ReferencedColumnsDontExist
from mathesar.functions.operations.convert import rewrite_db_function_spec_column_ids_to_names
from db.records.exceptions import BadGroupFormat, GroupFieldNotFound, InvalidGroupType

Expand Down Expand Up @@ -56,7 +56,7 @@ def list(self, request, table_pk=None):
grouping=serializer.validated_data['grouping'],
duplicate_only=serializer.validated_data['duplicate_only'],
)
except (BadDBFunctionFormat, UnknownDBFunctionId, ReferencedColumnsDontExist) as e:
except (BadDBFunctionFormat, UnknownDBFunctionID, ReferencedColumnsDontExist) as e:
raise database_api_exceptions.BadFilterAPIException(
e,
field='filters',
Expand Down
4 changes: 2 additions & 2 deletions mathesar/tests/api/test_record_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
from sqlalchemy_filters.exceptions import BadSortFormat, SortFieldNotFound

from db.functions.exceptions import UnknownDBFunctionId
from db.functions.exceptions import UnknownDBFunctionID
from db.records.exceptions import BadGroupFormat, GroupFieldNotFound
from db.records.operations.group import GroupBy
from mathesar import models
Expand Down Expand Up @@ -590,7 +590,7 @@ def test_record_404(create_table, client):


def test_record_list_filter_exceptions(create_table, client):
exception = UnknownDBFunctionId
exception = UnknownDBFunctionID
table_name = f"NASA Record List {exception.__name__}"
table = create_table(table_name)
filter = json.dumps({"empty": [{"column_name": ["Center"]}]})
Expand Down

0 comments on commit 9d85b5a

Please sign in to comment.