On Tue, Oct 23, 2001 at 03:28:04PM +0100, Simon Oliver wrote:
>
> Tim Bunce wrote:
> >
> > You won't get far without providing a strong case for *why*.
> >
> I have tried on a number of occasions but got no response so I decied to
> have a ago a creating a working, patched version and offering it up for
> RFC.
>
> And even if these changes are not accepted by the DBI community I might
> want to implement them locally and so it woul dbe nice to know how to do
> it.
>
> I want to add the following two methods and modify the tables method.
> These changes require four new attributes (see attached).
>
> The idea is that by using sensible default values for these attributes
> nothing will break. But as time goes by, we can start to use the
> build_identifier and quote_identifier methods wherever a method returns
> a database identifier. This will become more of an issue as more schema
> methods are added to the DBI specification. I expect the next release
> will contain methods like column_info, foreign_key_info and as we start
> to use this meta-data we will need a database independent way of
> identifying database objects.
Yes, yes. I agree and I plan to add something along these lines very soon.
(From your previous message you seemed to want to add *class* attributes
and that's what would need a strong case as it doesn't fit with the DBI's
approach to life.)
Tim.
> --
> Simon Oliver
>
> IdentifierColumns => [0,1,2]
> IdentifierSeparator => q{.}
> IdentifierQuoteStart => q{"}
> IdentifierQuoteEnd => q{"}
>
>
> sub build_identifier {
> my ($dbh, @ids) = @_;
> my $id = join $dbh->{IdentifierSeparator},
> map($dbh->quote_identifier($_), @ids);
> return $id;
> }
>
> sub quote_identifier {
> my ($dbh, $id, $qs, qe) = @_;
> return $id unless $dbh->{QuotedIdentifiers};
> my $id ||= '';
> my $qs ||= $dbh->{IdentifierQuoteStart};
> my $qe ||= $qs
> || $dbh->{IdentifierQuoteEnd}
> || $dbh->{IdentifierQuoteStart};
> return "$qs$id$qe";
> }
>
> sub tables {
> my ($dbh, @args) = @_;
> my $sth = $dbh->table_info(@args);
> return unless $sth;
> my ($row, @tables);
> while($row = $sth->fetch) {
> my @ids = ();
> foreach my $id (@$row[@{$dbh->{IdentifierColumns}}]) {
> push(@ids, $id) if defined $id;
> }
> push @tables, $dbh->build_identifier(@ids);
> }
> return @tables;
> }