Skip to content

[Feature Request]: zerofill  #6571

Closed
Closed

Description

@dengn

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

No response

Additional information

No response

Activity

  1. added
    priority/p0
    source/on-demand
    on Nov 14, 2022
  2. added this to the V0.7.0-Backlog milestone on Nov 14, 2022
  3. fengttt commented on Nov 17, 2022

    @fengttt
    Contributor

    Why isn't this a function? zerofill(number, 5) returns string.

  4. added
    attention/being-discussed
    and removed
    attention/being-discussed
    on Nov 22, 2022
  5. florashi181 commented on Nov 23, 2022

    @florashi181
    Contributor

    this solution is ok

  6. domingozhang commented on Nov 23, 2022

    @domingozhang
    Contributor

    decimal and int will be implemented first
    float and double depends on users' feedback

  7. aunjgr commented on Jan 8, 2023

    @aunjgr
    Contributor

    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.

  8. aunjgr commented on Jan 8, 2023

    @aunjgr
    Contributor

    Assigning this back to the author. Please let me know if you don't agree with my last comment.

  9. assigned and unassigned on Jan 8, 2023
  10. dengn commented on Jan 10, 2023

    @dengn
    ContributorAuthor

    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.

  11. modified the milestones: v0.7.0, Backlog on Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/featurepriority/p0source/on-demandtriage/accepted

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions