Closed mathemancer closed 1 month ago
This was discovered while putting together DB-layer logic for determining the valid_target_types
array for some types. Many (many) types consider mathesar_types.uri
to be a valid_target_type
(taking whether we have a custom cast function with that pair as the definition). We need to make sure only the correct target types are ... targeted ... by our custom casting functions for a given source type.
Description
The installation of cast functions currently creates many such functions which make no sense, and can only fail. For example, we create a function that attempts to cast a
bigint
to amathesar_types.email
. However, such a conversion is impossible. There's no such thing as a value which is both a valid integer and a valid email address.Expected behavior
Only cast functions which make sense should be installed.
The main issue seems to be the constant
db.types.categories.STRING_LIKE_TYPES
. We use this to construct a bunch of textual cast functions in thedb.types.operations.cast.create_textual_casts
function. However, we consider many types (e.g.,mathesar_types.email
to beSTRING_LIKE_TYPES
, and most don't make sense as the target of arbitrary casts from other arbitrary types.