[Dbix-class] Re: Using DBIx::Class with PostGIS geometry columns

Robert Rothenberg robrwo at gmail.com
Thu Jan 3 22:49:23 GMT 2013


I've come up with a solution at
http://stackoverflow.com/questions/14144155/is-there-any-way-to-filter-a-column-using-sql-functions-in-perls-dbixclass/14148455#14148455

Ideally, there's be a variant of InflateColumn that says to use a particular
database function for inflating, and another for deflating.
Can that be done with DBIC?

On 03/01/13 16:25 Robert Rothenberg wrote:
> I'm looking for a less painful way of using DBIx::Class with a database that
> has PostGIS geometry columns.
> 
> Ideally, I'd like to use InflateColumn to automatically inflate/deflate
> geometry columns using the ST_AsEWKT and ST_GeomFromEWKT functions, but I am
> unsure how to do this, or even if it's possible.
> 
> Using something like
> 
>   __PACKAGE__->inflate_column( 'geo', {
>     inflate => sub {
> 	my ($raw_value, $result) = @_;
> 	my $col = $result->get_column("geo")->func("ST_AsEWKT");
>     },
>   });
> 
> doesn't work, because $result->get_column() is returning the scalar value of
> the column instead of a ResultSetColumn object, which is annoying (and a bit
> confusing, since I've looked at the source for ResultSet and cannot
> understand why it's doing that).
> 
> Assuming I am able to get this to work in a similar manner, I'm still unsure
> how to implement deflate.
> 
> Any pointers would be helpful.
> 




More information about the DBIx-Class mailing list