FAQ
Hi

When I call create on a result set like the same in the catalyst
documentation like

my $book = $c->model('DB::Book')->create({title => $title,
rating => $rating });

I get the following error

DBIx::Class::ResultSet::create(): Unable to perform storage-dependent
operations with a detached result source (source '_unnamed_' is not
associated with a schema). at
./catalyst/test/script/../lib/test/Controller/Books.pm line 56

I am using the most up to date version of catalyst, DBIx::Class. I am
also using it with a MySQL backend.

Is there a setting I need to set so this error messages goes away and
insert records into the database? Has anyone had similar issues


I raised this issue with the DBIx::Class mailing list and they said:

The fix is to insert this line before you serialize the object:

# to let DBIC automatically pick up the correct schema in the child #
process after Storable freezed/thawed the result objects local

$DBIx::Class::ResultSourceHandle::thaw_schema = $rs->result_source->schema;

I am unsure where to put this in my application. Has anyone have ideas
how to resolve this

Regards

Gordon

Search Discussions

  • Alejandro Imass at Jul 28, 2011 at 3:16 pm

    On Tue, Jul 26, 2011 at 1:51 PM, wrote:
    Hi

    When I call create on a result set like the same in the catalyst
    documentation like

    ? ? ? ? ? ? ? my $book = $c->model('DB::Book')->create({title ?=> $title,
    rating => $rating });

    I get the following error

    DBIx::Class::ResultSet::create(): Unable to perform storage-dependent
    operations with a detached result source (source '_unnamed_' is not
    associated with a schema). at
    ./catalyst/test/script/../lib/test/Controller/Books.pm line 56
    Did you create the Schema classes yourself? or did you use the
    xxxx_create.pl script?

    I have found that static creation using the create helper script is
    the best solution because it gives you the flexibility to extend the
    DBIC model and it's also very easy to upgrade when your DB changes.
    The way to use the create script for DBIC is:

    script/xxxx_create.pl model [model_name] DBIC::Schema [namespace]
    create=static dbi:[sriver]:dbname=data/catmodels.db [user] [pass]


    --
    Alejandro Imass
  • Gordon at Jul 29, 2011 at 4:14 pm
    Alejandro

    I am using the create fuction catalyst provides, I find that is the best
    way of creating the model. Does it need 'source_name' in the classes
    that it creates.

    Regards

    Gordon

    On Tue, Jul 26, 2011 at 1:51 PM, wrote:
    Hi

    When I call create on a result set like the same in the catalyst
    documentation like

    ? ? ? ? ? ? ? my $book = $c->model('DB::Book')->create({title ?=>
    $title,
    rating => $rating });

    I get the following error

    DBIx::Class::ResultSet::create(): Unable to perform storage-dependent
    operations with a detached result source (source '_unnamed_' is not
    associated with a schema). at
    ./catalyst/test/script/../lib/test/Controller/Books.pm line 56
    Did you create the Schema classes yourself? or did you use the
    xxxx_create.pl script?

    I have found that static creation using the create helper script is
    the best solution because it gives you the flexibility to extend the
    DBIC model and it's also very easy to upgrade when your DB changes.
    The way to use the create script for DBIC is:

    script/xxxx_create.pl model [model_name] DBIC::Schema [namespace]
    create=static dbi:[sriver]:dbname=data/catmodels.db [user] [pass]


    --
    Alejandro Imass

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Alejandro Imass at Jul 31, 2011 at 2:55 pm

    On Fri, Jul 29, 2011 at 12:14 PM, wrote:
    Alejandro

    I am using the create fuction catalyst provides, ?I find that is the best
    way of creating the model. ?Does it need 'source_name' ?in the classes
    that it creates.

    Hi Gordon,

    To better help you, please indicate:

    - Operating System of the Catalyst App
    - RDBMS version and host OS
    - DBD (DBI Driver)
  • Gordon at Jul 31, 2011 at 4:18 pm

    To better help you, please indicate:

    - Operating System of the Catalyst App
    Ubuntu 8.04.4 LTS
    - RDBMS version and host OS
    Ubuntu 8.04.4 LTS using MySql 5.0.51a-3ubuntu5.8-log
    (same box as my catalyst application)
    - DBD (DBI Driver)
    DBIx::Class 0.08195
    DBIx::Class::Schema::Loader 0.07010
    DBIx::Class::Schema::Loader::DBI::mysql 0.07010
    DBIx::Class::Schema::Loader::DBI::SQLite 0.07010

    I get the same if I use sqllite or mysql so I think there is an issue with
    DBIx::Class.

    Gordon

    On Fri, Jul 29, 2011 at 12:14 PM, wrote:
    Alejandro

    I am using the create fuction catalyst provides, ?I find that is the
    best
    way of creating the model. ?Does it need 'source_name' ?in the classes
    that it creates.

    Hi Gordon,

    To better help you, please indicate:

    - Operating System of the Catalyst App
    - RDBMS version and host OS
    - DBD (DBI Driver)

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Alejandro Imass at Aug 1, 2011 at 8:10 pm

    On Sun, Jul 31, 2011 at 12:18 PM, wrote:
    To better help you, please indicate:

    - Operating System of the Catalyst App
    ? ? ? ? ?Ubuntu 8.04.4 LTS
    - RDBMS version and host OS
    ? ? ? ? ?Ubuntu 8.04.4 LTS using MySql ?5.0.51a-3ubuntu5.8-log
    ? ? ? ? ?(same box as my catalyst application)
    The Perl in 8.04 is probably quite old.
    - DBD (DBI Driver)
    ? ? ? ? ?DBIx::Class ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0.08195
    ? ? ? ? ?DBIx::Class::Schema::Loader ? ? ? ? ? ? ? 0.07010
    ? ? ? ? ?DBIx::Class::Schema::Loader::DBI::mysql ? 0.07010
    ? ? ? ? ?DBIx::Class::Schema::Loader::DBI::SQLite ?0.07010

    I get the same if I use sqllite or mysql so I think there is an issue with
    DBIx::Class.
    DBIx::Class works on top of the plain-old DBI/DBD scheme. So when I
    asked for the DBD I meant the actual DBI driver, examples:

    DBD::SQLite
    DBD::mysql
    DBD:;Pg

    Try static models like the following examples:

    When working with SQLite you must generate your model clases with the
    path to the DB file like so:

    script/[app]_create.pl model [model name] DBIC::Schema
    [app]::Schema::[model name] create=static
    dbi:SQLite:dbname=data/catmodels.db

    Assuming data/ exists from the root of the application

    When working with MySQL try something like this:

    script/[app]_create.pl model [model name] DBIC::Schema
    [app]::Schema::[model name] create=static dbi:mysql:[dbname] [user]
    [pass]

    If you are connecting to more than one DB just use different model
    names for each ;-)

    If the static model generation was successful you should be able to
    look inside the Schema Result classes and verify that you can actually
    see the relations defined in each class with every field, type and
    relationships (has_many, belongs_to etc.).

    If you are unable to generate the static DBIC model try a small
    program with plain-old DBI and see if you can actually connect to the
    DB and have the correct privileges to extract the schema.

    perldoc DBI

    Cheers,

    --
    Alejandro Imass




    Gordon

    On Fri, Jul 29, 2011 at 12:14 PM, ?wrote:
    Alejandro

    I am using the create fuction catalyst provides, ?I find that is the
    best
    way of creating the model. ?Does it need 'source_name' ?in the classes
    that it creates.

    Hi Gordon,

    To better help you, please indicate:

    - Operating System of the Catalyst App
    - RDBMS version and host OS
    - DBD (DBI Driver)

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/


    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Gordon at Aug 2, 2011 at 7:21 pm
    Hi

    I am running the most up todate version of the following

    On Sun, Jul 31, 2011 at 12:18 PM, wrote:
    To better help you, please indicate:

    - Operating System of the Catalyst App
    ? ? ? ? ?Ubuntu 8.04.4 LTS
    - RDBMS version and host OS
    ? ? ? ? ?Ubuntu 8.04.4 LTS using MySql ?5.0.51a-3ubuntu5.8-log
    ? ? ? ? ?(same box as my catalyst application)
    The Perl in 8.04 is probably quite old.
    - DBD (DBI Driver)
    ? ? ? ? ?DBIx::Class ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0.08195
    ? ? ? ? ?DBIx::Class::Schema::Loader ? ? ? ? ? ? ? 0.07010
    ? ? ? ? ?DBIx::Class::Schema::Loader::DBI::mysql ? 0.07010
    ? ? ? ? ?DBIx::Class::Schema::Loader::DBI::SQLite ?0.07010

    I get the same if I use sqllite or mysql so I think there is an issue
    with
    DBIx::Class.
    DBIx::Class works on top of the plain-old DBI/DBD scheme. So when I
    asked for the DBD I meant the actual DBI driver, examples:

    DBD::SQLite
    DBD::mysql
    DBD:;Pg

    Try static models like the following examples:

    When working with SQLite you must generate your model clases with the
    path to the DB file like so:

    script/[app]_create.pl model [model name] DBIC::Schema
    [app]::Schema::[model name] create=static
    dbi:SQLite:dbname=data/catmodels.db

    Assuming data/ exists from the root of the application

    When working with MySQL try something like this:

    script/[app]_create.pl model [model name] DBIC::Schema
    [app]::Schema::[model name] create=static dbi:mysql:[dbname] [user]
    [pass]

    If you are connecting to more than one DB just use different model
    names for each ;-)

    If the static model generation was successful you should be able to
    look inside the Schema Result classes and verify that you can actually
    see the relations defined in each class with every field, type and
    relationships (has_many, belongs_to etc.).

    If you are unable to generate the static DBIC model try a small
    program with plain-old DBI and see if you can actually connect to the
    DB and have the correct privileges to extract the schema.

    perldoc DBI

    Cheers,

    --
    Alejandro Imass




    Gordon

    On Fri, Jul 29, 2011 at 12:14 PM, ?wrote:
    Alejandro

    I am using the create fuction catalyst provides, ?I find that is the
    best
    way of creating the model. ?Does it need 'source_name' ?in the classes
    that it creates.

    Hi Gordon,

    To better help you, please indicate:

    - Operating System of the Catalyst App
    - RDBMS version and host OS
    - DBD (DBI Driver)

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/


    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Gordon at Aug 2, 2011 at 7:37 pm
    Alejandro

    I am running uptodate version of DBD::mysql(4.019) and DBD::SQLite(1.33),
    but the issue is not with me creating the schema that works fine. The
    problem is with creating a record via the model as described in the
    catalyst documentation


    my $book = $c->model('DB::Book')->create({title => $title,
    rating => $rating });

    I get the following error

    DBIx::Class::ResultSet::create(): Unable to perform storage-dependent
    operations with a detached result source (source '_unnamed_' is not
    associated with a schema). at
    ./catalyst/test/script/../lib/test/Controller/Books.pm line 56

    Gordon

    On Sun, Jul 31, 2011 at 12:18 PM, wrote:
    To better help you, please indicate:

    - Operating System of the Catalyst App
    ? ? ? ? ?Ubuntu 8.04.4 LTS
    - RDBMS version and host OS
    ? ? ? ? ?Ubuntu 8.04.4 LTS using MySql ?5.0.51a-3ubuntu5.8-log
    ? ? ? ? ?(same box as my catalyst application)
    The Perl in 8.04 is probably quite old.
    - DBD (DBI Driver)
    ? ? ? ? ?DBIx::Class ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0.08195
    ? ? ? ? ?DBIx::Class::Schema::Loader ? ? ? ? ? ? ? 0.07010
    ? ? ? ? ?DBIx::Class::Schema::Loader::DBI::mysql ? 0.07010
    ? ? ? ? ?DBIx::Class::Schema::Loader::DBI::SQLite ?0.07010

    I get the same if I use sqllite or mysql so I think there is an issue
    with
    DBIx::Class.
    DBIx::Class works on top of the plain-old DBI/DBD scheme. So when I
    asked for the DBD I meant the actual DBI driver, examples:

    DBD::SQLite
    DBD::mysql
    DBD:;Pg

    Try static models like the following examples:

    When working with SQLite you must generate your model clases with the
    path to the DB file like so:

    script/[app]_create.pl model [model name] DBIC::Schema
    [app]::Schema::[model name] create=static
    dbi:SQLite:dbname=data/catmodels.db

    Assuming data/ exists from the root of the application

    When working with MySQL try something like this:

    script/[app]_create.pl model [model name] DBIC::Schema
    [app]::Schema::[model name] create=static dbi:mysql:[dbname] [user]
    [pass]

    If you are connecting to more than one DB just use different model
    names for each ;-)

    If the static model generation was successful you should be able to
    look inside the Schema Result classes and verify that you can actually
    see the relations defined in each class with every field, type and
    relationships (has_many, belongs_to etc.).

    If you are unable to generate the static DBIC model try a small
    program with plain-old DBI and see if you can actually connect to the
    DB and have the correct privileges to extract the schema.

    perldoc DBI

    Cheers,

    --
    Alejandro Imass




    Gordon

    On Fri, Jul 29, 2011 at 12:14 PM, ?wrote:
    Alejandro

    I am using the create fuction catalyst provides, ?I find that is the
    best
    way of creating the model. ?Does it need 'source_name' ?in the classes
    that it creates.

    Hi Gordon,

    To better help you, please indicate:

    - Operating System of the Catalyst App
    - RDBMS version and host OS
    - DBD (DBI Driver)

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/


    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Tomas Doran at Aug 2, 2011 at 7:41 pm

    On 2 Aug 2011, at 20:37, gordon@gorste.plus.com wrote:

    Alejandro

    I am running uptodate version of DBD::mysql(4.019) and
    DBD::SQLite(1.33),
    but the issue is not with me creating the schema that works fine. The
    problem is with creating a record via the model as described in the
    catalyst documentation


    my $book = $c->model('DB::Book')->create({title =>
    $title,
    rating => $rating });

    I get the following error

    DBIx::Class::ResultSet::create(): Unable to perform storage-dependent
    operations with a detached result source (source '_unnamed_' is not
    associated with a schema). at
    ./catalyst/test/script/../lib/test/Controller/Books.pm line 56
    DBIC appears totally broken here..

    Can you show us your model class + the dbic schema and Book result
    class..

    Maybe you'd be better off jumping into #catalyst or #dbix-class on irc
    to get this one sorted out quickly?

    Cheers
    t0m

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJul 26, '11 at 5:51p
activeAug 2, '11 at 7:41p
posts9
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase