[Dbix-class] how to determine column is inflatable?

Carl Franks fireartist at gmail.com
Fri Jan 30 10:25:19 GMT 2009


2009/1/30 Ash Berlin <ash_cpan at firemirror.com>:
>
> On 30 Jan 2009, at 08:56, Carl Franks wrote:
>
>> 2009/1/29 Ash Berlin <ash_cpan at firemirror.com>:
>>>
>>> On 29 Jan 2009, at 22:03, Carl Franks wrote:
>>>
>>>> Is it okay to use $result_source->column_info('name')->{_inflate_info}
>>>> to test whether a column is inflatable / deflatable?
>>>> It seems a bit too reliant on internals, to me.
>>>>
>>>> Or should there be a has_inflatable_column('name') method?
>>>>
>>>> (and is that what it should be called? do we really also need a
>>>> 'has_deflatable_column' too?)
>>>>
>>>> If someone makes a call, I'll write up a patch for it.
>>>>
>>>> Carl
>>>>
>>>
>>> There doesn't seem to be a public way to determine this, and indeed
>>> accessing anything starting with an _ indicates badness.
>>>
>>> First things first - what exactly do you care if a column is inflated or
>>> not?
>>
>> In HTML-FormFu-Model-DBIC, I can't just use get/set_column(),
>> otherwise in/deflators won't get called.
>> So I've had to document that people can't name fields after DBIC
>> built-in methods such as 'delete', otherwise when we call $row->$name
>> it'll trash your db.
>>
>> What I'd like to do is allow the use of any name, by doing something like
>> this:
>>
>>   $value = $row->result_source->has_inflated_column
>>       ? $row->get_inflated_column( $name )
>>       : $row->get_column( $name );
>>
>>   $row->result_source->has_inflated_column
>>       ? $row->set_inflated_column( $name, $value )
>>       : $row->set_column( $name, $value );
>>
>> I can't just use get/set_inflated_column() for everything, as it
>> croaks if there's no in/deflator for a column.
>
>
> And why can't you just do $row->$name() or $row->$name($value) ? (I'm sure
> there's a reason, I'm just curious as to what it is.)

If the column name clashes with a DBIC method, such as 'delete', we've
got a problem.

Carl



More information about the DBIx-Class mailing list