Ticket#33647 : bulk_update silently truncating values for size limited fieldsApproach 1:As mentioned by Simon in this
comment we can introduce a new argument maybe named
generic in the database function
Cast similar to the following
Cast(expr, ArrayField(CharField(max_length=20), generic=True).
Although as mentioned by Mariusz in this
comment "we cannot introduce new keyword arguments into database function that will be only be used to fix usage elsewhere in the Django code."
But the explanation is still a little unclear to me, it would be great if someone can explain the reason.
Approach 2:
As we will not be able to introduce a new new keyword arguments into database function we can create a new database function named something like GenericCast,That will cast according to the type only without specifying the maximum length.
I would like to move forward with the Approach 2. Some feedback would be great.