Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node

2017-07-25 Thread Craig Ringer
On 26 July 2017 at 07:12, Alvaro Herrera wrote: > Chapman Flack wrote: > > > Any takers if I propose this amendment in the form of a patch? > > > > Relying on the perl idiom instead of a $node->isa() test shortens > > the patch; does that ameliorate at all the concern about complicating > > core

Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node

2017-07-25 Thread Alvaro Herrera
Chapman Flack wrote: > Any takers if I propose this amendment in the form of a patch? > > Relying on the perl idiom instead of a $node->isa() test shortens > the patch; does that ameliorate at all the concern about complicating > core for the benefit of modules? Yeah, I like this (I also got wor

Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node

2017-06-07 Thread Chapman Flack
On 06/02/17 15:51, Chapman Flack wrote: > But what it buys you is then if your MyExtraPGNode has PostgresNode > as a base, the familiar idiom > > MyExtraPGNode->get_new_node('foo'); > > works, as it inserts the class as the first argument. > > As a bonus, you then don't need to complicate get_

Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node

2017-06-02 Thread Chapman Flack
On 06/02/2017 12:50 PM, Robert Haas wrote: > On Thu, Jun 1, 2017 at 3:36 AM, Michael Paquier >> >> +$pgnclass = 'PostgresNode' unless defined $pgnclass; >> I'd rather leave any code of this kind for the module maintainers, > > Craig's proposal is a standard Perl idiom, though. Would it not be

Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node

2017-06-02 Thread J Chapman Flack
On 06/02/2017 12:50 PM, Robert Haas wrote: > On Thu, Jun 1, 2017 at 3:36 AM, Michael Paquier >> >> +$pgnclass = 'PostgresNode' unless defined $pgnclass; >> I'd rather leave any code of this kind for the module maintainers, > > Craig's proposal is a standard Perl idiom, though. Would it not be

Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node

2017-06-02 Thread Robert Haas
On Thu, Jun 1, 2017 at 3:36 AM, Michael Paquier wrote: > On Wed, May 31, 2017 at 7:18 PM, Craig Ringer wrote: >> Note that you can achieve the same effect w/o patching >> PostgresNode.pm, albeit in a somewhat ugly manner, by re-blessing the >> returned object. >> >> sub get_new_mywhatever_node {

Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node

2017-06-01 Thread Tels
Moin, On Wed, May 31, 2017 10:18 pm, Craig Ringer wrote: > On 31 May 2017 at 08:43, Craig Ringer wrote: >> Hi all >> >> More and more I'm finding it useful to extend PostgresNode for project >> specific helper classes. But PostgresNode::get_new_node is a factory >> that doesn't provide any mechan

Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node

2017-06-01 Thread Michael Paquier
On Wed, May 31, 2017 at 7:18 PM, Craig Ringer wrote: > Note that you can achieve the same effect w/o patching > PostgresNode.pm, albeit in a somewhat ugly manner, by re-blessing the > returned object. > > sub get_new_mywhatever_node { > my $self = PostgresNode::get_new_node($name); >

Re: [HACKERS] TAP: allow overriding PostgresNode in get_new_node

2017-05-31 Thread Craig Ringer
On 31 May 2017 at 08:43, Craig Ringer wrote: > Hi all > > More and more I'm finding it useful to extend PostgresNode for project > specific helper classes. But PostgresNode::get_new_node is a factory > that doesn't provide any mechanism for overriding, so you have to > create a PostgresNode then r

[HACKERS] TAP: allow overriding PostgresNode in get_new_node

2017-05-30 Thread Craig Ringer
Hi all More and more I'm finding it useful to extend PostgresNode for project specific helper classes. But PostgresNode::get_new_node is a factory that doesn't provide any mechanism for overriding, so you have to create a PostgresNode then re-bless it as your desired subclass. Ugly. The attached