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

  • Home
  • SEARCH
  • 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 6701671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:57:43+00:00 2026-05-26T06:57:43+00:00

package testDB; use Moose; use Carp; use SQL::Library; has ‘lib’ => (#FOLDBEG is =>

  • 0
package testDB;
use Moose;
use Carp;
use SQL::Library;

has 'lib' => (#FOLDBEG
    is => 'rw',
    isa => 'Str',
    default => 'default',
    trigger => \&_sql_lib_builder,
);#FOLDEND

has 'lib_dir' => (#FOLDBEG
    is => 'ro',
    isa => 'Str',
    default => '/SQL',
);#FOLDEND

has '_sql_lib' => (#FOLDBEG                                                                                                                            
   builder => '_sql_lib_builder',
    is => 'rw',
    isa => 'Str',
);

has '_sql_lib' => (#FOLDBEG                                                                                                                            
    builder => '_sql_lib_builder',
    is => 'rw',
           handles => {
        get_sql => 'retr',
        get_elements => 'elements',
    },
);

sub _sql_lib_builder {
    my ($self, $lib) = shift();
    $self->lib() or die("I am unable to get a lib.");
    $lib = $self->lib unless $lib;


    my $lib_dir = $self->lib_dir;
    print $lib_dir."\n";

    my $lib_file = $lib_dir . '/' . $lib . '.sql';

    unless (-e $lib_file ) {
        confess "SQL library $lib does not exist";
    }

    my $library = new SQL::Library { lib => $lib_file };

    $self->_sql_lib($library);

}#FOLDEND

__PACKAGE__->meta->make_immutable;

my $tdb=testDB->new();

Using perl 5.8.8 and Moose 2.0205

$ perl testDB.pl 
I am unable to get a lib. at testDB.pl line 35.
  • 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-05-26T06:57:44+00:00Added an answer on May 26, 2026 at 6:57 am

    You’ve defined the _sql_lib attribute twice, once saying isa Str and once saying it handles methods (which a Str doesn’t), but that’s not the problem you’re talking about.

    The main problem is that you didn’t define _sql_lib with lazy => 1. Any attribute whose builder (or default) depends on other attributes of the object must be lazy, because Moose doesn’t guarantee the order in which attributes are assigned values during object construction.

    # REMOVE THIS:
    #has '_sql_lib' => (#FOLDBEG                                 
    #   builder => '_sql_lib_builder',
    #    is => 'rw',
    #    isa => 'Str',
    #);
    
    has '_sql_lib' => (#FOLDBEG                                 
        builder => '_sql_lib_builder',
        is => 'rw',
        lazy => 1,                       # ADD THIS LINE
        handles => {
            get_sql => 'retr',
            get_elements => 'elements',
        },
    );
    

    The reason that make_immutable brings out the bug is that calling it generates a different constructor for your class, which happens to initialize the attributes in a different order.

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

Sidebar

Related Questions

package JustTesting; use strict; use warnings; sub new { my $self = {}; bless($self,
/** * */ package ORM; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; /** * @author
I'm trying to use Oracle LogMiner ( DBMS_LOGMNR package) for implementation of audit trails
package database; import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import database.Dbconnect; public class
Package Load Failure Package 'Microsoft.VisualStudio.Xaml' has failed tot load properly. . . yadda, yadda,
package com.fitaxis.test; import java.sql.SQLException; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer;
package pack; public class sample{ public static void main(String input[]) { NumberFormat numberFormat =
package test; import java.awt.*; import java.awt.event.*; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import javax.swing.*; public class
package { import mx.controls.LinkButton; import flash.text.TextLineMetrics; public class multiLineLinkButton extends LinkButton { override protected
package org.study.algos; public class Study { public static void main(String[] args) { A a

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.