adding a new enum sets historical data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jamie
    Senior Member
    • Aug 2025
    • 308

    #1

    adding a new enum sets historical data

    when i create a new enum it will set all records to the default, every single one of them. it should just set it as null
  • victor
    Active Community Member
    • Aug 2022
    • 1185

    #2
    You just need to add an empty Option and make it Default (this is how it always worked).
    Attached Files

    Comment

    • jamie
      Senior Member
      • Aug 2025
      • 308

      #3
      Originally posted by victor
      You just need to add an empty Option and make it Default (this is how it always worked).
      ahh some undocumented hack, perhaps its time to update documentation or maybe don't automatically set historical data?

      Comment

      • yuri
        EspoCRM product developer
        • Mar 2014
        • 9827

        #4
        The default value is set as DB default for all fields with scalar values. It's how it works. There are pros and cons in it. I'd rather keep it as it is.

        Comment

      • jamie
        Senior Member
        • Aug 2025
        • 308

        #5
        Originally posted by yuri
        The default value is set as DB default for all fields with scalar values. It's how it works. There are pros and cons in it. I'd rather keep it as it is.
        setting historical data a major con, and the fact that it isn't documented is also another con, if your going to make non standard behavior you should at least document it, though the best would be a check box to toggle the behavior

        Comment

        • yuri
          EspoCRM product developer
          • Mar 2014
          • 9827

          #6

          It's how databases have been always working. The default value populates existing records if a null is not allowed. The application does not do it, it's the behavior of the database. Calling it a non-standard behavior is a moot point. It's already added to the docs, no need to re-iterate the same.

          Comment

          • jamie
            Senior Member
            • Aug 2025
            • 308

            #7
            but its not an normal enum its a text field with limited options still very annoying that it automatically sets historical data, if it really was an enum in the db i could see the argument but it isn't so there is no reason to go and set all the historical data and give no option to not set it,

            so when you set a text filed does it also set the default in all historical data?

            Comment

            • yuri
              EspoCRM product developer
              • Mar 2014
              • 9827

              #8
              The solution was suggested. It's not a hack, it's a logical solution. You can set the field required so that users are not able to save the field with an empty value.

              If one added by a mistake and it populated unwanted values, just remove the field and run hard rebuild. The column will be dropped.

              ---

              Example 1.

              Options:

              - No
              - Yes


              Default: No

              When we create such a field, it sets for the column: Default = 'No'. The DB automatically populates the 'No' value. The records are automatically in a valid state. Null would have been an invalid domain value, as null is not in options.


              Example 2.

              Options:

              - Empty
              - No
              - Yes


              Default: Empty

              When we create such a field, the DB sets all existing records to null.


              ---

              > so there is no reason to go and set all the historical data and give no option to not set it

              I'll re-iterate. We do not "go and set all historical data". We don't have such a logic. It's the behavior of the database. You should rather argue with the creators of the database systems.

              While there might no reasons for you, there can be reasons for some, there where cases where this was a desired behavior. The field is automatically in a valid state for all existing records. I prefer to not to participate in discussions where absolutist argumentation such as "so there is no reason" based on a not strong logic is used.

              You can always modify the source code as it's open source and free software.

              Comment

              Working...