Review main Merged

74281[FEATURE] Auto creation of database fields for TCA "datetime"

Oli Bartsch CR +2 V +2 Normal +61 −19 updated 04/19/22, 18:54

Commit message

To further support extension authors, the DefaultTcaSchema
is extended to automatically create database fields for
TCA type "datetime" columns. In case no native database
type is used, the fields are defined as INT, according
to #97358.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Stefan Bürk +1
    • Nikita Hovratov +1
  • Verified V +2 Done
    • Benni Mack +2
    • Stefan Bürk +1
    • Nikita Hovratov +1
    • core-ci +1 CI

Issues 3

Files 11

Review log 3341

Show 1016 earlier messages
  1. Oli Bartsch uploaded patch set 1 04/12/22, 12:48

  2. core-ci voted on patch set 1 V +1 04/12/22, 13:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25954

  3. Oli Bartsch uploaded patch set 2 04/12/22, 21:19

  4. core-ci voted on patch set 2 V +1 04/12/22, 21:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25962

  5. Oli Bartsch uploaded patch set 3 04/12/22, 21:54

  6. core-ci voted on patch set 3 V +1 04/12/22, 22:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25963

  7. Oliver Klee commented on patch set 3 04/13/22, 08:19

    Breaking-97358-RemovedEvalintFromTCATypeDatetime.rst:27

    Typo: correspodning -> corresponding
  8. Stefan Bürk commented on patch set 4 04/13/22, 08:58

    Published edit on patch set 3.
  9. Stefan Bürk commented on patch set 4 04/13/22, 08:58

    Breaking-97358-RemovedEvalintFromTCATypeDatetime.rst:27 Reply

    Done
  10. core-ci voted on patch set 4 V -1 04/13/22, 09:13 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25970

  11. core-ci voted on patch set 4 V +1 04/13/22, 09:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25970

  12. Oliver Klee wrote 04/13/22, 10:10

    Removed cc Oliver Klee.
  13. Stefan Bürk voted on patch set 4 V +1 CR +1 04/13/22, 13:20

  14. Nikita Hovratov uploaded patch set 5 04/13/22, 16:18

  15. core-ci voted on patch set 5 V +1 04/13/22, 16:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25992

  16. Stefan Bürk voted on patch set 5 V +1 CR +1 04/13/22, 16:59

  1. Nikita Hovratov voted on patch set 5 V +1 CR +1 04/13/22, 17:40

  2. Benni Mack commented on patch set 5 04/14/22, 11:10

    If we really go this way, we should start also use the change from @georgringer to auto-create other TCA fields dynamically.
  3. Stefan Bürk commented on patch set 5 04/14/22, 11:28

    Reply

    @benny Which one do you mean ? Should we do a patch with more auto tca generation. There is an issue from Oliver Hader for auto creating "slug" fields from tca. Wanted to do that in a dedicated patch on the weekend - should we combine them ? I think rather not .. or ?
  4. Benni Mack commented on patch set 5 04/14/22, 11:29

  5. Oli Bartsch commented on patch set 5 04/14/22, 12:36

    Reply

    Pleas note that this patch is not about auto TCA generation but about auto database field generation, based on TCA.
  6. Benni Mack commented on patch set 5 04/14/22, 12:48

    sorry, different idea from Georg.
  7. Benni Mack commented on patch set 5 04/14/22, 21:02

    DefaultTcaSchema.php:497

    should we use the 'default' from TCA?
  8. Daniel Windloff commented on patch set 5 04/15/22, 10:06

    DefaultTcaSchema.php:51

    I suggest to rename "enrichSingleTableFields" to "enrichSingleTableFieldsByCtrl" and add something like "enrichSingleTableFieldsByColumn" to carify the source and add the new code there.

    DefaultTcaSchema.php:206

    The field generation of starttime and endtime could be removed.

    DefaultTcaSchema.php:499

    'unsigned' => true? It is unsigned in generated endtime fields. The removed lines in .sql file are also unsigned.
  9. Stefan Bürk commented on patch set 5 04/15/22, 10:18

    DefaultTcaSchema.php:51 Reply

    Yeah, sounds resonable. However not part or job of this patch. Please create a dedicated patch for it if you want to change this.

    DefaultTcaSchema.php:206 Reply

    Can you explain why they should be removed ? However, not related or part of this patch. Please create a dedicated patch where this can be discussed than. We should try to stay in the context of a patch and which is directly related.

    DefaultTcaSchema.php:497 Reply

    I think we should not use the TCA default here, but not sure in both directions * it's kind of unusual to have default values other then 0 for time/date fields on dbms level * TCA default should be more used in the backend * changes on TCA default, through other extensions or instances requires a database compare afterwards (and eventually update wizards) Maybe I'm wrong, but I would take the TCA default for DataHander/FORMS default only. And there can be more default changes anyway.

    DefaultTcaSchema.php:499 Reply

    Nope, that's correct. 'unsigned' => false is needed to support negative values, thus date/time values before 1970. We are talking here about default field generation - so extension developers do not need to define fields in 'ext_tables.sql' but have the best suitable field definition for this. Thus opening values before 1970. Granted, removed fields has been unsigned, which are now changed to signed. Mostly eventually not needed, but still does not hurt in any way. Removing them from core 'ext_table.sql' files and using the default will remove a small maintenance burden.
  10. Daniel Windloff commented on patch set 5 04/15/22, 10:44

    DefaultTcaSchema.php:51 Reply

    It is the first field creation based on columns here (excluding MM tables). That's why I think it could be part of this change.

    DefaultTcaSchema.php:206 Reply

    The relation is, that starttime and endtime are of type datetime. There is no need for an additional creation with this patch included.
  11. Nikita Hovratov commented on patch set 5 04/15/22, 11:03

    DefaultTcaSchema.php:206 Reply

    It's not 100% sure the fields are defined as datetime by the user. Custom fields can be defined for ['ctrl']['enablecolumns']['starttime'], which might as well be simple number fields and are not filled in the backend, but from another data source.
  12. Stefan Bürk commented on patch set 5 04/15/22, 11:09

    DefaultTcaSchema.php:206 Reply

    For core, ack. As long they stay defined as this. But the DefaultTCA generation is not only for core definitions. Additional this part creates the database definition only based on the ctrl definition, the colume do not have to exists with a proper "column" type definitions. So if there would be no "column" definition, field would not be auto created. I think we should: * keep them * add check that it is not defined as datetime as tca table column So, if it is a datetime column definition, let the new code create the database definition. If only enablecolumns is defined without column tca type datetime, use this code here. What do you think ?
  13. Daniel Windloff commented on patch set 5 04/15/22, 11:12

    DefaultTcaSchema.php:499 Reply

    Yes, there are different use cases for datetime fields. The signed / unsigned could be set based on the ['config']['range']['lower'] setting. If it is greater or equal 0, it should be unsigned.
  14. Daniel Windloff commented on patch set 5 04/15/22, 11:21

    DefaultTcaSchema.php:51 Reply

    Ok, missed the categories :)
  15. Daniel Windloff commented on patch set 5 04/15/22, 11:36

    DefaultTcaSchema.php:206 Reply

    Sounds good. I didn't have different configured columns in mind. I think, the main thing here is, that it should be clear, if column config overwrites ctrl or not.
  16. Oli Bartsch uploaded patch set 6 04/19/22, 10:48

  17. Oli Bartsch commented on patch set 6 04/19/22, 10:53

    DefaultTcaSchema.php:206 Reply

    The columns config should not override ctrl config, which is kind of special and might not be defined in $TCA[columns] at all. I adjusted the corresponding comment.

    DefaultTcaSchema.php:497 Reply

    This TCA option is not reliable here, because the option can be overridden "dynamically" e.g. with `columnsOverrides`. If the proposed schema definition does not match, extension authors add the suited definition manually.

    DefaultTcaSchema.php:499 Reply

    This TCA option is not reliable here, because the option can be overridden "dynamically" e.g. with `columnsOverrides`. If the proposed schema definition does not match, extension authors add the suited definition manually.
  18. Stefan Bürk voted on patch set 6 V +1 CR +1 04/19/22, 10:53

  19. core-ci voted on patch set 6 V +1 04/19/22, 10:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26181

  20. Nikita Hovratov uploaded patch set 7 04/19/22, 13:06

  21. Nikita Hovratov voted on patch set 7 V +1 CR +1 04/19/22, 13:12

  22. core-ci voted on patch set 7 V +1 04/19/22, 13:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26187

  23. Stefan Bürk commented on patch set 7 V +1 CR +1 04/19/22, 13:29

    Thx Nikita for the nullable correction.
  24. Benni Mack voted on patch set 7 V +2 CR +2 04/19/22, 18:54

  25. Benni Mack merged patch set 8 04/19/22, 18:54