How do I get the value of a foreign key rather than the object?

Viewed 210

I've got two tables, book and language; book belongs_to language by having a language column stating which language it's in. The language table is just the language column.

I want to do $book->language and get the language string, without fetching the language from the language table. Is there a way to do that?

I suspect it's about return context. Should I do some sort of overload, say:

use overload "language_string" => sub {
  my $self = shift;
  return $self->language;
}, fallback => 1;

But in that case I'm, of course, still getting the language.

1 Answers
Related