You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there an existing issue for the same feature request?
I have checked the existing issues.
Is your feature request related to a problem?
No response
Describe the feature you'd like
When numeric types and decimal types are used in conjunction with the optional (nonstandard) ZEROFILL attribute, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(4) ZEROFILL, a value of 5 is retrieved as 0005.
This should apply for int, float,double, decimal(M,N)
Describe implementation you've considered
No response
Documentation, Adoption, Use Case, Migration Strategy
There's actually no need to implement a new zerofill function. lpad can cover all cases. zerofill(some_numeric_val, 5) is identical to lpad(some_numeric_val, 5, '0').
And according to mysql's documentation, zerofill should only support unsigned numeric types. So don't bother handling negative values with lpad.
Starting with the idea of developing it as a function instead of DDL statement, this feature has already been incompatible with MySQL. We haven't really encountered any application problem related to this zerofill behavior yet, so I will accept it for now.
Activity
fengttt commentedon Nov 17, 2022
Why isn't this a function? zerofill(number, 5) returns string.
florashi181 commentedon Nov 23, 2022
this solution is ok
domingozhang commentedon Nov 23, 2022
decimal and int will be implemented first
float and double depends on users' feedback
aunjgr commentedon Jan 8, 2023
There's actually no need to implement a new
zerofillfunction.lpadcan cover all cases.zerofill(some_numeric_val, 5)is identical tolpad(some_numeric_val, 5, '0').And according to mysql's documentation,
zerofillshould only support unsigned numeric types. So don't bother handling negative values withlpad.aunjgr commentedon Jan 8, 2023
Assigning this back to the author. Please let me know if you don't agree with my last comment.
dengn commentedon Jan 10, 2023
Starting with the idea of developing it as a function instead of DDL statement, this feature has already been incompatible with MySQL. We haven't really encountered any application problem related to this zerofill behavior yet, so I will accept it for now.