-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM-13123 - Add serialization metadata to schema #11394
Conversation
I quite like this idea and i think it would be quite worthwhile thoughts @totten @eileenmcnaughton. @colemanw i think we should put in searlisation for |
Another +1 on the general concept of adding this to the metadata. It does make sense that this would go into APIv4 -- that pasture is green enough this metadata can bring some rewards. Looking at the list of serialization mechanisms, SEPARATOR_BOOKEND, PHP, and JSON feel like the most common in the current schema. I raised an eyebrow at two of the serialization mechanisms:
Aside: If you like oddballs, I'd be tempted for the metadata to simply name the serialize/deserialize callback. |
I've always been concerned that storing serialized data when the DB doesn't provide good tools for understanding it is an antipattern that should be looked at sceptically. MySQL has made great strides with JSON support over the last many years. Adding metadata about these fields is generally a good idea, so longas it doesn't encourage inappropriate proliferation of new serialized fields. |
@@ -173,15 +173,11 @@ static function &fields() { | |||
'type' => CRM_Utils_Type::T_TEXT, | |||
'title' => ts('Domain Configuration') , | |||
'description' => 'Backend configuration.', | |||
'rows' => 20, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come we lost html definition off these fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cause it's not an html field in any sense that I can tell. The html tags were originally added by someone with not much familiarity with the db and they're still not used for much of anything so I think it's safe to remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
I think this is a good change - I would just suggest that some comments be added to the functions / constants to make it clear what is the preferred format for new fields. |
@totten I think it would be fine to add another constant for As for your two raised eyebrows (is that both eyes?) I agree the Are there any fields in the db that use a comma? I thought there were some but now I can't find them so maybe we don't need that constant. |
|
This should be documented. I opened a ticket for it: https://github.com/civicrm/civicrm-dev-docs/issues/463 |
CRM-13123 - Add serialization metadata to schema
Overview
This PR adds metadata to the schema for use by Api4. It doesn't change any functionality in core but adds some helper functions.
Technical Details
Tags each serialized field in the schema with information about how they are being serialized (I've identified 5 different ways a field might be serialized and defined constants for each).
Adds some functions for serializing and unserializing a given field. These functions aren't called from anywhere in core (yet) but will be used by api4.
Adds a unit test for the serialization functions.
CRM-13123: Handle value-separated fields at the dao level