Resolve logic duplication in the db.types namespace #1100
Labels
affects: architecture
Improvements or additions to architecture
affects: technical debt
Improves the state of the codebase
ready
Ready for implementation
type: enhancement
New feature or request
work: backend
Related to Python, Django, and simple SQL
Milestone
Problem
@mathemancer pointed out that some of the logic in
db.types.base::_build_db_types_hinted
is a duplicate of logic indb.types.operations.cast
(see global variablesTEXT_TYPES
andNUMBER_TYPES
). Specifically it's the logic that describes which types are string-like and which are number-like. This suggests that we could centralize this logic.Proposed solution
Not totally clear. A new file in the
db.types
namespace that would hold lists of database types, each list grouping types according to some attribute, like them being string-like or number-like.A slight complication is that the
db.types.base
method expects those types to be expressed as Enum instances, whiledb.types.operations.cast
expects them to be type ID strings. You could say that the former wants to convert from Enum to string as late as possible, while the latter as early as possible.The text was updated successfully, but these errors were encountered: