Discussion:
[devinfo] DB weirdness
John Crisp
2018-10-09 12:53:54 UTC
Permalink
So,

I was hacking a bit of code for my docker contrib.

I wanted to try and remove an existing key like this:

#!/usr/bin/perl

use esmith::ConfigDB;
my $configDB = esmith::ConfigDB->open_ro or die("can't open
Config DB");
my $networksDB = esmith::ConfigDB->open('networks') or die("cant connect
to networks database");


So now I 'just' want to delete a particular property like this (entirely
missing the point that it *should* be del_prop to match set_prop which
wasted a pile of time....):

$networksDB->delete_prop( "$dockerAddr", "Docker" );

Except it wont delete the property.

Jumps to to ConfigDB.pm sub AUTLOAD which seems to check for the called
subroutine name eg del_prop in 'services'

my ($called_sub_name) = ( $AUTOLOAD =~ m/([^:]*)$/ );
my @types = qw( services );
if ( grep /^$called_sub_name$/, @types )


Don't get that at all.....

However, if we change to this:

$networksDB->get_prop_and_delete( "$dockerAddr", "Docker" );

That jumps straight to the DB.pm file, retrieves the property and then
deletes.

I can see that there are two 'delete_prop' subs

[***@home esmith]# grep -rn sub\ delete_prop *
ConfigDB/unsaved.pm:42:sub delete_prop {
DB/db/Record.pm:215:sub delete_prop {

Should I have 'used' a different library?

Anyone care to explain what is going on as it has driven me in circles
this morning !!

B. Rgds
John
_______________________________________________
Server Development Discussion
To unsubscribe, e-mail devinfo-***@lists.contribs.org
Searchable archive at https://lists.contribs.org/mailman/public/devinfo/
Loading...