Gossamer Forum
Quote Reply
Documentation Error:
Alex,

A typo in the docs for plugins:

Code:
Examples
1. Your install needs to add a custom column named 'Review' to
the Links Table To do this we will need a GT::SQL::Editor object.

my $editor = $DB->table ('Links');
unless ($editor->add_col ( 'Review', { type => 'TEXT' }) {
$Plugins::Pluginname::error = "Unable to add column to Links: $GT::SQL::error";
return;
}
Note the missing ')' in the 'unless' line.

Also, wouldn't a better example be something like:

Code:
my $table = $DB->table('Links');
my %cols = $table->cols;
if (!(exists $cols{'Review'})) {
my $editor = $DB->editor('Links');
unless ($editor->add_col ( 'Review', { type => 'TEXT' }) ) {
$Plugins::Pluginname::error = "Unable to add column to Links: $GT::SQL::error";
return;
}
} else {
$Plugins::Pluginname::error = "Unable to add column to Links, column already exists";
}
PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Quote Reply
Re: Documentation Error: In reply to
Theres also an extra capital letter on the second line.

To

Ooops now that I look it is a missing .

Paul Wilson.
Installations:
http://www.wiredon.net/gt/
Quote Reply
Re: Documentation Error: In reply to
Hi,

I've changed it to:

Code:
unless (exists $DB->table('Links')->cols->{'Review'}) {
my $editor = $DB->table ('Links');
unless ($editor->add_col ( 'Review', { type => 'TEXT' }) {
$Plugins::Pluginname::error = "Unable to add column to Links: $GT::SQL::error";
return;
}
}
Or is this a little confusing (the chaining of functions) and I should spell it out a little more.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Documentation Error: In reply to
I'll have to check function by function, but "unless" is sort of like double negatives, or that really weird set of and/or stuff on the categories.

Thing is, if it works, and it's a standard way to add a field, then it's fine :)

It looks like it takes all the possibilities into account.

This is one of those cut/paste things where the way you suggest will become the 99% default method, without people even thinking about it. After all, the install only runs once, so having it WORK is much more important than having it be an efficient work of art :)




PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum