Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:57:13+00:00 2026-06-02T11:57:13+00:00

I have two class that are linked on foreign.weirdkey => substr(self.key, 1, 9) …and

  • 0

I have two class that are linked on

foreign.weirdkey => substr(self.key, 1, 9)

…and cannot for the life of me figure out how to construct the has_many call to indicate this.

The underlying database (a set of Oracle tables) defines no foreign keys, is fixed, and is outside of my control.

I’ve been through the docs and can’t seem to find a syntax that will work within the confines of a manual has_many definition.

Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:57:16+00:00Added an answer on June 2, 2026 at 11:57 am

    something like this should work:

    __PACKAGE__->has_many( baubles => 'My::Schema::Result::Thing', sub {
       my $args = shift;
    
       return ({
          "$args->{foreign_alias}.weirdkey" => \"substr($args->{self_alias}.key, 1, 9)",
       },
       $args->{self_rowobj} && {
          "$args->{foreign_alias}.weirdkey" => substr($args->{self_rowobj}->key, 1, 9)
       })
    });
    

    Note that I use perl’s substr if you have the current row object, so then the join will collapse into merely a where clause and won’t use the database for the string munging. Remove that or fiddle with it if you have problems. DBIC_TRACE should make it clear what goes on.

    Documentation here: https://metacpan.org/pod/DBIx::Class::Relationship::Base#condition

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two objects that are linked by a foreign key relationship and I
I have a class that contains two sets. They both contain the same key
I have created two classes, class A that uses a Linked List and class
I have three models linked by foreign keys: class One(models.Model): ... class Two(models.Model): one
I have a Runnable class that I'm writing. Inside of it, I have two
I have two different projects and in one, I have a class that defines
I have these two methods on a class that differ only in one method
We have two projects that are both class libraries. Project 1 is a VS
I have a class that instantiates two classes which implement interfaces. I want one
I have a class that contains objects of two other classes. I need one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.