Am 23.08.2013 16:19, schrieb Jeroen De Dauw:
Hey,
In the database, we (generally) have the numeric
ID and entity type. How
do we construct an ItemId from that?
See the code ;) Serialization was already encapsulated, so only some local
changes are needed for this. Users in general do not know about the db
serialization format.
The serialization format is an external, canonical representation. The database
form is internal and may change. Isn't that the reason we also have two JSON
representations for entities?
Also, I'm
afraid this change means that we'll start using the serialized
form internally,
because it's convenient. I still think that this is a bad
idea, even if the prefix is no longer configurable.
We did originally use the serialized form, and thus have many of those in
the db. The code that handled this legacy format is now once again the main
code handling the current one. (I'm rather amused by that.)
As far as I know, the only place where we have the serialized form in a DB field
is wb_changes.change_object_id. Everything else uses two separate fields. This
is quite annoying, since it makes it impossible to join the changes table
against one of the other wb tables.
This certainly is convenient, thus we need good reason
to not go with it.
Why do you think it is a bad idea? What problems will it cause? And why are
we not seeing those problems already with the current legacy serializations?
The only problem we are seeing is caused by the inconsistency described above.
I think it is generally a bad idea to tie the database schema to a specific
serialization. Encoding multiple things into a single field in the database is
generally smelly, even though it's useful in some cases.
I don't see a huge problem with using the prefixed ID in the database - but
considering that we use separate fields almost everywhere, we should stick to
that approach.
Also, configurable or not, the knowledge of the prefixes should be in a single
piece of code, so it can be easily changed (and make configurable again). I
really don't want to see code sticking a "q" to a number all over the
place.
-- daniel