From: janw Date: Mon, 30 Mar 2009 10:05:36 +0000 (+0000) Subject: Don't loose schema definition internally to allow easy re-creation of database. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=888c7322e51a28c651b61cdad7d372fcb4319c55;p=gosa.git Don't loose schema definition internally to allow easy re-creation of database. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13569 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/trunk/gosa-si/modules/DBsqlite.pm b/trunk/gosa-si/modules/DBsqlite.pm index 0a4f5d97c..161f15413 100644 --- a/trunk/gosa-si/modules/DBsqlite.pm +++ b/trunk/gosa-si/modules/DBsqlite.pm @@ -15,7 +15,6 @@ sub new { my $class = shift; my $db_name = shift; - #my $lock = $db_name.".si.lock"; my $lock = $db_name; my $self = {dbh=>undef,db_name=>undef,db_lock=>undef,db_lock_handle=>undef}; my $dbh = DBI->connect("dbi:SQLite:dbname=$db_name", "", "", {RaiseError => 1, AutoCommit => 1, PrintError => 0}); @@ -86,16 +85,11 @@ sub create_table { my @col_names; my @col_names_creation; foreach my $col_name (@$col_names_ref) { - # Save full column description for creation of database - push(@col_names_creation, $col_name); - my @t = split(" ", $col_name); - my $column_name = $t[0]; - # Save column name internally for select_dbentry - push(@col_names, $column_name); + push(@col_names, $col_name); } $col_names->{ $table_name } = \@col_names; - my $col_names_string = join(", ", @col_names_creation); + my $col_names_string = join(", ", @col_names); my $sql_statement = "CREATE TABLE IF NOT EXISTS $table_name ( $col_names_string )"; my $res = $self->exec_statement($sql_statement); @@ -270,15 +264,17 @@ sub get_table_columns { my @column_names; if(exists $col_names->{$table}) { - @column_names = @{$col_names->{$table}}; + foreach my $col_name (@{$col_names->{$table}}) { + push @column_names, ($1) if $col_name =~ /^(.*?)\s.*$/; + } } else { my @res; foreach my $column ( $self->exec_statement ( "pragma table_info('$table')" ) ) { push(@column_names, @$column[1]); } } - return \@column_names; + return \@column_names; }