FAQ
This is more of any annoying error message if anything. So bear with me.

Basically I am setting global template variables (TT) within the
Controller::Root to be used within all the template pages within the
application. Everything works with exception to this annoying warning,
"Model::CDBI::Catalog::sql_category redefined at
/usr/lib/perl5/site_perl/5.8.3/Ima/DBI.pm".

I have narrowed the problem down to the Class::DBI set_sql() method and how
it temporarily creates a method sql_* within the Model::CDBI upon execution.

Anyone experience this or know of a solution to suppress this warning?

Is this something I should be worrying about?

Thank your time, Catalyst::Rocks.

Search Discussions

  • Marcello Romani at Jun 6, 2006 at 6:41 am

    Marc Brooks ha scritto:
    This is more of any annoying error message if anything. So bear with me.

    Basically I am setting global template variables (TT) within the
    Controller::Root to be used within all the template pages within the
    application. Everything works with exception to this annoying warning,
    "Model::CDBI::Catalog::sql_category redefined at
    /usr/lib/perl5/site_perl/5.8.3/Ima/DBI.pm".

    I have narrowed the problem down to the Class::DBI set_sql() method and how
    it temporarily creates a method sql_* within the Model::CDBI upon execution.

    Anyone experience this or know of a solution to suppress this warning?

    Is this something I should be worrying about?

    Thank your time, Catalyst::Rocks.



    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst
    Sorry for the silly question, but have you tried renaming the method ?

    --
    Marcello Romani
    Responsabile IT
    Ottotecnica s.r.l.
    http://www.ottotecnica.com
  • Marc Brooks at Jun 6, 2006 at 4:16 pm
    The problem is the method doesn't exist until the query is executed using
    set_sql().

    When performing a query using

    $c->model('MyApp::Example')->set_sql( example => qq{
    SELECT * FROM just_an_example WHERE just = 1
    });

    The Class::DBI inherits Ima::DBI's set_sql() to create a helper shortcut
    method, by prefixing the name of the SQL fragment with "search_". Thus, the
    above call to set_sql() will automatically set up the method
    search_example(), which will then perform the query.

    So the answer to your question is no because the method doesn't exist.

    Thanks for your time

    M. Brooks

    -----Original Message-----
    From: catalyst-bounces at lists.rawmode.org
    [mailto:catalyst-bounces at lists.rawmode.org]On Behalf Of Marcello Romani
    Sent: Monday, June 05, 2006 11:42 PM
    To: The elegant MVC web framework
    Subject: Re: [Catalyst] Class::DBI, Controller::Root, set_sql
    "redefined" [heur] poss. spam[ff]


    Marc Brooks ha scritto:
    This is more of any annoying error message if anything. So bear with me.

    Basically I am setting global template variables (TT) within the
    Controller::Root to be used within all the template pages within the
    application. Everything works with exception to this annoying warning,
    "Model::CDBI::Catalog::sql_category redefined at
    /usr/lib/perl5/site_perl/5.8.3/Ima/DBI.pm".

    I have narrowed the problem down to the Class::DBI set_sql() method and how
    it temporarily creates a method sql_* within the Model::CDBI upon
    execution.
    Anyone experience this or know of a solution to suppress this warning?

    Is this something I should be worrying about?

    Thank your time, Catalyst::Rocks.



    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst
    Sorry for the silly question, but have you tried renaming the method ?

    --

    Marcello Romani
    Responsabile IT
    Ottotecnica s.r.l.
    http://www.ottotecnica.com

    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst
  • Aran Deltac at Jun 6, 2006 at 5:10 pm

    On 6/6/06, Marc Brooks wrote:
    The problem is the method doesn't exist until the query is executed using
    set_sql().

    When performing a query using

    $c->model('MyApp::Example')->set_sql( example => qq{
    SELECT * FROM just_an_example WHERE just = 1
    });

    The Class::DBI inherits Ima::DBI's set_sql() to create a helper shortcut
    method, by prefixing the name of the SQL fragment with "search_". Thus, the
    above call to set_sql() will automatically set up the method
    search_example(), which will then perform the query.
    Its generally accepted by most Catalyst developers that DBIx::Class is
    a superior solution to Class::DBI. You'll find that DBIx::Class is
    much more sane about how it handles these sorts of situations.
    Consider making the switch if you can. :)

    Aran
    So the answer to your question is no because the method doesn't exist.

    Thanks for your time

    M. Brooks

    -----Original Message-----
    From: catalyst-bounces at lists.rawmode.org
    [mailto:catalyst-bounces at lists.rawmode.org]On Behalf Of Marcello Romani
    Sent: Monday, June 05, 2006 11:42 PM
    To: The elegant MVC web framework
    Subject: Re: [Catalyst] Class::DBI, Controller::Root, set_sql
    "redefined" [heur] poss. spam[ff]


    Marc Brooks ha scritto:
    This is more of any annoying error message if anything. So bear with me.

    Basically I am setting global template variables (TT) within the
    Controller::Root to be used within all the template pages within the
    application. Everything works with exception to this annoying warning,
    "Model::CDBI::Catalog::sql_category redefined at
    /usr/lib/perl5/site_perl/5.8.3/Ima/DBI.pm".

    I have narrowed the problem down to the Class::DBI set_sql() method and how
    it temporarily creates a method sql_* within the Model::CDBI upon
    execution.
    Anyone experience this or know of a solution to suppress this warning?

    Is this something I should be worrying about?

    Thank your time, Catalyst::Rocks.



    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst
    Sorry for the silly question, but have you tried renaming the method ?

    --

    Marcello Romani
    Responsabile IT
    Ottotecnica s.r.l.
    http://www.ottotecnica.com

    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst

    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst
  • Marc Brooks at Jun 6, 2006 at 5:21 pm
    The problem at hand though is the complexity of the statements I am using.
    I use the set_sql() from the Class::DBI since I can naturally write my
    statements. Does the DBIx::Class have an equivalent of the set_sql()?

    EXAMPLE:

    SELECT *
    FROM catalog AS node1, catalog AS node2
    WHERE node2.lft BETWEEN node1.lft AND node1.rgt
    AND $level = (
    SELECT COUNT(*)
    FROM catalog AS node3
    WHERE node3.lft BETWEEN node1.lft AND node1.rgt
    AND node2.lft BETWEEN node3.lft AND node3.rgt
    AND node3.id
    NOT IN (node2.id, node1.id)
    )
    AND node2.id != node1.id AND node1.id = '$id'


    -----Original Message-----
    From: catalyst-bounces at lists.rawmode.org
    [mailto:catalyst-bounces at lists.rawmode.org]On Behalf Of Aran Deltac
    Sent: Tuesday, June 06, 2006 10:10 AM
    To: The elegant MVC web framework
    Subject: Re: [Catalyst] Class::DBI, Controller::Root, set_sql
    "redefined" [heur] poss. spam[ff]

    On 6/6/06, Marc Brooks wrote:
    The problem is the method doesn't exist until the query is executed using
    set_sql().

    When performing a query using

    $c->model('MyApp::Example')->set_sql( example => qq{
    SELECT * FROM just_an_example WHERE just = 1
    });

    The Class::DBI inherits Ima::DBI's set_sql() to create a helper shortcut
    method, by prefixing the name of the SQL fragment with "search_". Thus, the
    above call to set_sql() will automatically set up the method
    search_example(), which will then perform the query.
    Its generally accepted by most Catalyst developers that DBIx::Class is
    a superior solution to Class::DBI. You'll find that DBIx::Class is
    much more sane about how it handles these sorts of situations.
    Consider making the switch if you can. :)

    Aran
    So the answer to your question is no because the method doesn't exist.

    Thanks for your time

    M. Brooks

    -----Original Message-----
    From: catalyst-bounces at lists.rawmode.org
    [mailto:catalyst-bounces at lists.rawmode.org]On Behalf Of Marcello Romani
    Sent: Monday, June 05, 2006 11:42 PM
    To: The elegant MVC web framework
    Subject: Re: [Catalyst] Class::DBI, Controller::Root, set_sql
    "redefined" [heur] poss. spam[ff]


    Marc Brooks ha scritto:
    This is more of any annoying error message if anything. So bear with
    me.
    Basically I am setting global template variables (TT) within the
    Controller::Root to be used within all the template pages within the
    application. Everything works with exception to this annoying warning,
    "Model::CDBI::Catalog::sql_category redefined at
    /usr/lib/perl5/site_perl/5.8.3/Ima/DBI.pm".

    I have narrowed the problem down to the Class::DBI set_sql() method and how
    it temporarily creates a method sql_* within the Model::CDBI upon
    execution.
    Anyone experience this or know of a solution to suppress this warning?

    Is this something I should be worrying about?

    Thank your time, Catalyst::Rocks.



    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst
    Sorry for the silly question, but have you tried renaming the method ?

    --

    Marcello Romani
    Responsabile IT
    Ottotecnica s.r.l.
    http://www.ottotecnica.com

    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst

    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst
    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst
  • Adam Jacob at Jun 6, 2006 at 6:11 pm

    On Jun 6, 2006, at 10:21 AM, Marc Brooks wrote:

    The problem at hand though is the complexity of the statements I am
    using.
    I use the set_sql() from the Class::DBI since I can naturally write my
    statements. Does the DBIx::Class have an equivalent of the set_sql()?

    EXAMPLE:

    SELECT *
    FROM catalog AS node1, catalog AS node2
    WHERE node2.lft BETWEEN node1.lft AND node1.rgt
    AND $level = (
    SELECT COUNT(*)
    FROM catalog AS node3
    WHERE node3.lft BETWEEN node1.lft AND node1.rgt
    AND node2.lft BETWEEN node3.lft AND node3.rgt
    AND node3.id
    NOT IN (node2.id, node1.id)
    )
    AND node2.id != node1.id AND node1.id = '$id'
    It has that, and so much more. DBIx::Class works by letting you
    create ResultSet's from your data; looking at the database from the
    point of view of getting the data you want out of it (and inflating
    that data into an object you can use). While DBIx::Class doesn't
    have direct support for sub-selects (yet) you can still accomplish
    them quite easily.

    Love the DBIx::Class. It doesn't solve every problem, but it solves
    the vast majority of them.. and where it makes compromises they tend
    to be acceptable ones.

    Adam
  • Len Jaffe at Jun 7, 2006 at 12:30 am

    --- Marc Brooks wrote:
    statements. Does the DBIx::Class have an equivalent
    of the set_sql()?

    EXAMPLE:

    SELECT *
    FROM catalog AS node1, catalog AS node2
    WHERE node2.lft BETWEEN node1.lft AND
    node1.rgt
    AND $level = (
    SELECT COUNT(*)
    FROM catalog AS node3
    WHERE node3.lft BETWEEN node1.lft
    AND node1.rgt
    AND node2.lft BETWEEN node3.lft
    AND node3.rgt
    AND node3.id
    NOT IN (node2.id, node1.id)
    )
    AND node2.id != node1.id AND node1.id =
    '$id'
    I'm surprised SQL expresses that at all. It looks like
    your writing a relational calculus algorithm to braid
    hair...

    BTW: you should replace '$id' with a bind variable or
    the SQL injection gremlins will get you.
  • Marc Brooks at Jun 6, 2006 at 6:36 pm
    So basically I must emulate the set_sql() method using the CDBICompat
    (Class::DBI Ima::DB). By doing so still doesn't solve my initial issue. On
    another note can the DBIx::Class handle complex updates like the one below.
    Sorry about all the questions. I didn't come across any examples from
    within the DBIx::Class documentation.

    UPDATE catalog
    SET lft = lft + CASE
    WHEN $rgt2 < $lft1
    THEN CASE
    WHEN lft BETWEEN $lft1 AND $rgt1
    THEN $rgt2 - $lft1
    WHEN lft BETWEEN $rgt2 AND $lft1 - 1
    THEN $rgt1 - $lft1 + 1
    ELSE 0 END
    WHEN $rgt2 > $rgt1
    THEN CASE
    WHEN lft BETWEEN $lft1 AND $rgt1
    THEN $rgt2 - $rgt1 - 1
    WHEN lft BETWEEN $rgt1 + 1 AND $rgt2 - 1
    THEN $lft1 - $rgt1 - 1
    ELSE 0 END
    ELSE 0 END,
    rgt = rgt + CASE
    WHEN $rgt2 < $lft1
    THEN CASE
    WHEN rgt BETWEEN $lft1 AND $rgt1
    THEN $rgt2 - $lft1
    WHEN rgt BETWEEN $rgt2 AND $lft1 - 1
    THEN $rgt1 - $lft1 + 1
    ELSE 0 END
    WHEN $rgt2 > $rgt1
    THEN CASE
    WHEN rgt BETWEEN $lft1 AND $rgt1
    THEN $rgt2 - $rgt1 - 1
    WHEN rgt BETWEEN $rgt1 + 1 AND $rgt2 - 1
    THEN $lft1 - $rgt1 - 1
    ELSE 0 END
    ELSE 0 END;

    -----Original Message-----
    From: catalyst-bounces at lists.rawmode.org
    [mailto:catalyst-bounces at lists.rawmode.org]On Behalf Of Adam Jacob
    Sent: Tuesday, June 06, 2006 11:11 AM
    To: The elegant MVC web framework
    Subject: Re: [Catalyst] Class::DBI, Controller::Root, set_sql
    "redefined" [ff]

    On Jun 6, 2006, at 10:21 AM, Marc Brooks wrote:

    The problem at hand though is the complexity of the statements I am
    using.
    I use the set_sql() from the Class::DBI since I can naturally write my
    statements. Does the DBIx::Class have an equivalent of the set_sql()?

    EXAMPLE:

    SELECT *
    FROM catalog AS node1, catalog AS node2
    WHERE node2.lft BETWEEN node1.lft AND node1.rgt
    AND $level = (
    SELECT COUNT(*)
    FROM catalog AS node3
    WHERE node3.lft BETWEEN node1.lft AND node1.rgt
    AND node2.lft BETWEEN node3.lft AND node3.rgt
    AND node3.id
    NOT IN (node2.id, node1.id)
    )
    AND node2.id != node1.id AND node1.id = '$id'
    It has that, and so much more. DBIx::Class works by letting you
    create ResultSet's from your data; looking at the database from the
    point of view of getting the data you want out of it (and inflating
    that data into an object you can use). While DBIx::Class doesn't
    have direct support for sub-selects (yet) you can still accomplish
    them quite easily.

    Love the DBIx::Class. It doesn't solve every problem, but it solves
    the vast majority of them.. and where it makes compromises they tend
    to be acceptable ones.

    Adam


    _______________________________________________
    Catalyst mailing list
    Catalyst at lists.rawmode.org
    http://lists.rawmode.org/mailman/listinfo/catalyst
  • Brandon Black at Jun 6, 2006 at 7:11 pm

    On 6/6/06, Marc Brooks wrote:
    On
    another note can the DBIx::Class handle complex updates like the one below.
    Sorry about all the questions. I didn't come across any examples from
    within the DBIx::Class documentation.
    That begs for a stored procedure in the language of your choice.

    -- Brandon
  • Matt S Trout at Jun 7, 2006 at 3:01 pm

    Marc Brooks wrote:
    So basically I must emulate the set_sql() method using the CDBICompat
    (Class::DBI Ima::DB). By doing so still doesn't solve my initial issue. On
    another note can the DBIx::Class handle complex updates like the one below.
    Sorry about all the questions. I didn't come across any examples from
    within the DBIx::Class documentation.
    No. Don't do that. CDBICompat is a porting springboard. Expect to use it
    briefly while getting your code converted across, if at all.

    For examples of complex updates have a look at the (as-yet unreleased)
    DBIx::Class::Tree component available at
    http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class-Tree/ which is
    design to eventually support an implementation of nested sets (which is
    what you've got there).

    I'd note that set_sql is the Wrong Thing to be doing in Class::DBI for
    your use case anyway; it's a class method you should be calling once to
    create the sql_Name and search_Name methods and then using those, which
    is why calling it repeatedly is giving you warnings. DBIx::Class doesn't
    have set_sql because if you *really* need totally custom SQL it's
    trivial to write a method to do so, and 99.9% of the time you don't.

    You'd be better off subscribing to the DBIx-Class list and discussing it
    there - it'd be more on-topic and we can get a proper discussion going
    about this and maybe make some progress on nested sets in ::Tree too :)

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJun 5, '06 at 11:36p
activeJun 7, '06 at 3:01p
posts10
users7
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase