Skip to content

Commit

Permalink
Merge pull request #3564 from mathesar-foundation/rm_cast_func
Browse files Browse the repository at this point in the history
Remove nonsensical cast_to_email and cast_to_uri functions
  • Loading branch information
mathemancer committed May 9, 2024
2 parents a61f61d + d1d2cee commit b4de3de
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
5 changes: 3 additions & 2 deletions db/records/operations/relevance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from sqlalchemy import case, select, desc
from db.types import categories
from db.types.base import MathesarCustomType
from db.types.operations.convert import get_db_type_enum_from_class

WEIGHT_4 = 4
Expand Down Expand Up @@ -37,8 +38,8 @@ def _get_scored_selectable(relation, parameters_dict):

def _get_col_score_expr(col, param_val):
col_type = get_db_type_enum_from_class(col.type.__class__)

if col_type in categories.STRING_LIKE_TYPES:
searchable_string_types = categories.STRING_LIKE_TYPES | frozenset([MathesarCustomType.URI, MathesarCustomType.EMAIL])
if col_type in searchable_string_types:
score_expr = case(
(col.ilike(param_val), WEIGHT_4),
(col.ilike(param_val + '%'), WEIGHT_3),
Expand Down
2 changes: 0 additions & 2 deletions db/types/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
*STRING_TYPES,
PostgresType.CHAR,
PostgresType.NAME,
MathesarCustomType.URI,
MathesarCustomType.EMAIL,
})

INTEGER_TYPES = frozenset({
Expand Down
6 changes: 0 additions & 6 deletions db/types/operations/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def get_column_cast_expression(column, target_type, engine, type_options=None):

def install_all_casts(engine):
create_boolean_casts(engine)
create_date_casts(engine)
create_decimal_number_casts(engine)
create_email_casts(engine)
create_integer_casts(engine)
Expand All @@ -64,11 +63,6 @@ def create_boolean_casts(engine):
create_cast_functions(PostgresType.BOOLEAN, type_body_map, engine)


def create_date_casts(engine):
type_body_map = _get_date_type_body_map()
create_cast_functions(PostgresType.DATE, type_body_map, engine)


def create_json_casts(engine):
json_types = categories.JSON_TYPES
for db_type in json_types:
Expand Down

0 comments on commit b4de3de

Please sign in to comment.