Dynamically Adding Columns to a DBIx::Class ResultSet

I have a DBIx::Class object representing an eBay auction. The underlying table has a description column which contains a lot of data. The description column is almost never used, so it's not included in the DBIx::Class column list for that table. That way, most queries don't fetch the auction description data.

I do, however, have one script that needs this column. In this one case, I want to access the contents of the description column as I would any other column:


How can I accomplish this without forcing all other queries to fetch the description column?


In older versions of DBIx::Class (not sure of the version number), the following used to work:

my $rs = $schema->resultset('Auctions');
my $lots = $rs->search(
   { '+select' => 'description', '+as' => 'description' },

That doesn't seem to work for row updates under modern versions of DBIx::Class. Trying that with an update

$auction->update({ description => '...'})

under DBIx::Class 0.08123 gives the following error: "DBIx::Class::Relationship::CascadeActions::update(): No such column description at ..."

Assuming that the script needing the extra column is running in its own process. You can do something like this:

my $rs = $schema->resultset('Auctions');

Of course, that's a global change. After adding the column, other code in the same process will start fetching the description column in queries. Not to mention, it's kind of ugly.

Need Your Help

Dividing a 2x32 bit big integer by 1000

c++ algorithm bignum

I have big number, time (micro seconds) stored in two 32bit variables.

How to pass input variable to SQL statement in R shiny?

r shiny shinyapps

Usually, variables can be passed to SQL statements using paste. Interestingly this doesn't work with input variables in R shiny. Using the below code I get the following error message. How can I so...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.