[Koha-bugs] [Bug 22159] Add ColumnExists method

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jan 18 02:53:39 CET 2019


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22159

--- Comment #1 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
Created attachment 84174
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=84174&action=edit
Bug 22159: Add ColumnExists method

This patch adds a method for checking if a column exists on a DB table.
The way this is checked is used already on updatedatabase.pl [1] (i.e.
querying INFORMATION_SCHEMA.

To test:
- Create an atomicupdate file like this:
  $ cd installer/data/mysql/atomicupdate
  $ cp skeleton.perl test.perl
- Change the contents of test.perl so it looks like this:
$DBversion = 'XXX';
if( CheckVersion( $DBversion ) ) {

    if ( ColumnExists( 'borrowers', 'firstname' ) ) {
        print "Column borrowers.firstname exists!";
    }
    else {
        print "Boo, borrowers.firstname wasn't detected";
    }

    if ( ColumnExists( 'borrowers', 'friendly_alias' ) ) {
        print "Great, there's no borrowers.firend_alias";
    }
    else {
        print "Boo, this is really wrong";
    }
}

- Run:
  $ updatedatabase
  or
  $ kshell
 k$ perl installer/data/mysql/updatedatabase.pl
=> SUCCESS: No 'Boo' message is printed
- Sign off :-D

[1] See 3.03.00.023 or 18.12.00.002

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list