How to access fields from both joined tables in a SearchBuilder object

Dear all,

I believe I reached the correct place for a question about
DBIx::SearchBuilder,
otherwise please forgive my noise.

I read the module documentation, the “RT Essential” book, I crawled this ML
archives, as well as google, and I gave a look at RT source code,
however I admit
I did not dive very deep in Tickets.pm generic query code, but I did not
find
a clear answer to this question :

Can you access fields from both joined tables in your result set
when you join two tables with Searchbuilder ?

You SearchBuilder-derived class is connected to one table (through
$self->Table(‘mytable’); ) and you thus return records of a
SearchBuilder::Record
type linked to this base table.

Should I :

  • forget using SearchBuilder for this purpose, it can not do it. period,
  • create a proper view in my database, and create a SearchBuilder object
    accordingly,
    thus working around the SearchBuilder “limitation” described here,
  • go back to “Modeling 101” and learn why what I want to do is bad.
    Please, teach me.
  • use the splendid solution you will certainly describe here. :slight_smile:

NB: I thought about the two following solutions, but I want to know if
there is
a better (more general) way :

  1. I may define my tables so I don’t need to perform a Join in the first
    place to
    get related informations, but I’m afraid normalization might suffer
    outrages here.
  2. Alternately, I may access my two tables separately (with a
    SearchBuilder object
    each) and “join” in the perl code, but I’m afraid I will call this a kludge.

Best regards,
Mathieu

Dear all,

I believe I reached the correct place for a question about
DBIx::SearchBuilder,
otherwise please forgive my noise.

I read the module documentation, the “RT Essential” book, I crawled this ML
archives, as well as google, and I gave a look at RT source code,
however I admit
I did not dive very deep in Tickets.pm generic query code, but I did
not find
a clear answer to this question :

Can you access fields from both joined tables in your result set
when you join two tables with Searchbuilder ?

Unfortunately, you can’t. If views perform well in your database
choice, that may be a solution. This is why you will often see RT
code that loops and goes and fetches more data.

-kevin