Re: [CDBI] mysql compress support
[prev]
[thread]
[next]
[Date index for 2005/08/30]
On 29 Aug 2005, at 02:15, Ilia Lobsanov wrote:
> Hello,
>
> How would I seamlessly use mysql's 'compress' string function (zlib
> integration) with Class::DBI?
>
> By "seamlessly", I mean I want Class::DBI to compress/uncompress upon
> insert/select using the mysql syntax.
There are a few options, depending on how widely you want this to
happen, but they're not very nice. Class::DBI encourages a few kinds
of modification but makes any others very difficult. You can't even
do this by overriding the standard sql statements because they tend
to just use a %s placeholder for all their parameters, and cdbi's
storage or retrieval operations usually take the form sql_Foo(join
(columns)), like this line in _flesh():
@row{@want} = $self->sql_Flesh(join ", ", @want)->select_row
($self->id);
What you really want is to insert a map block in that join statement
and expand each parameter to include the decompression syntax. You'd
have to override them one by one. Not a small job.
Here are some ideas, anyway:
1. subclass or replace DBIx::ContextualFetch and (selectively?)
modify query parameters to add the compress and decompress syntax.
This will be quite messy and very sensitive to cdbi versions, but it
should work.
2. improve Class::DBI's subclassability and submit patches to Tony.
This probably just means adding an empty method call or two to the
preparation of each statement, and should be quite easy to do even
though it affects a great many lines.
3. wait for the interesting but slow refactoring of Class::DBI that
should follow the release of version 1, if Tony has any enthusiasm
left. It will bring more structure to columns and attributes and
should provide the sort of hook you need.
4. investigate the alternative ORM solutions, especially John
Siracusa's Rose::DB, which I think is turning into a better choice
than cdbi. It already has a much better object structure and looks
like it will offer the sort of hook you need to tweak column
retrieval very easily. I haven't used it properly yet so can't be sure.
I actually quite like number 2, especially as Tony is working on a
release. I'd like to see more low-level hooks in the sql generation.
He has said that v1 will only see bug fixes rather than new features,
though: you should definitely talk to him before doing any work.
Sorry I can't see an easier answer,
will
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
|
(message missing)
|