App-DBBrowser

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


2.400  2023-12-18
        - Changed SQL submenu behavior.
        - New scalar functions.
        - New extension to set aliases for all selected columns.
        - Fixes for submenus HAVING and ORDER_BY when in aggregate mode.
        - Updates for option alias.
        - Update aggregate mode.
        - Catch table-print execute errors earlier.
        - Removed backwards compatibility for old f_attached_db and f_subqueries format.
        - Use Clone to backup data.
        - Term::Choose::Util minimum version '0.140'.
        - Update documentation.

2.345_05  2023-12-09
        - Fixes for submenus HAVING and ORDER when in aggregate mode.
        - Update aggregate mode.
        - Update CTEs.
        - Update option alias for derived tables and non-unique columns in join.
        - Bugfix backup data in join.
        - Update documentation.

2.345_04  2023-11-16
        - Bugfixes in the HAVING submenu.
        - Removed option 'fast_reset'.
        - Catch table-print execute errors earlier.

2.345_03  2023-10-28
        - Use Clone to backup data.
        - New option 'fast_reset'.

2.345_02  2023-10-23
        - Bugfixes, updates and cleanups.

2.345_01  2023-10-21
        - Changed SQL submenu behavior.
        - Removed backwards compatibility for old f_attached_db and f_subqueries format.
        - Added scalar new functions.
        - Added extension to set aliases for all selected columns.

Changes  view on Meta::CPAN

        - New option 'Info'.
        - Update write access.

2.042    2019-01-11
        - Join: possibility to use a subquery instead of a table.
        - Join: option to choose the comparison operator.
        - Remove duplicates in history.
        - Bugfix: avoid double quoting in saved subqueries.

2.041    2019-01-09
        - Bugfix in join: backup aliases.
        - Update join menus.
        - Attached databases: make menus less noisy.
        - Code refactoring.

2.040    2019-01-07
        - MySQL and Pg databases: added 'autoincrement' options.
        - Bugfix in 'get_schemas'.

2.039    2019-01-06
        - Bugfix in join.

Changes  view on Meta::CPAN


0.026   2014-04-28
        - Improved documentation.

0.025   2014-04-26
        - SQL menu entry "COLUMNS" is now called "SELECT".
        - Code refactoring.
        - Improved documentation.

0.024   2014-04-21
        - Bugfix in "backup_in_hidd".
        - It is possible now also with "GROUP BY" to choose more than one column at once.
        - Update documentation.

0.023   2014-04-10
        - Update documentation.

0.022   2014-03-24
        - Update "ALL TABLES" in UNION.
        - Mininum version of "Term::TablePrint" is now 0.005.
        - Update Makefile.PL

lib/App/DBBrowser/Auxil.pm  view on Meta::CPAN

        i => $info,
        o => $options,
        d => $d
    }, $class;
}


sub reset_sql {
    my ( $sf, $sql ) = @_;
    # preserve base data: table name, column names and data types:
    my $backup = {
        table => $sql->{table} // '',
        columns => $sql->{columns} // [],
        data_types => $sql->{data_types} // {},
    };
    # reset/initialize:
    delete @{$sql}{ keys %$sql }; # not "$sql = {}" so $sql is still pointing to the outer $sql
    my @string = qw( distinct_stmt set_stmt where_stmt having_stmt order_by_stmt limit_stmt offset_stmt );
    my @array  = qw( group_by_cols selected_cols set_args order_by_cols
                     ct_column_definitions ct_table_constraints ct_table_options
                     insert_col_names insert_args );
    my @hash   = qw( alias );
    @{$sql}{@string} = ( '' ) x  @string;
    @{$sql}{@array}  = map{ [] } @array;
    @{$sql}{@hash}   = map{ {} } @hash;
    for my $y ( keys %$backup ) {
        $sql->{$y} = $backup->{$y};
    }
}


sub __stmt_fold {
    my ( $sf, $term_w, $used_for, $stmt, $indent ) = @_;
    if ( $used_for eq 'print' ) {
        my $in = ' ' x $sf->{o}{G}{base_indent};
        my %tabs = ( init_tab => $in x $indent, subseq_tab => $in x ( $indent + 1 ) );
        return line_fold( $stmt, { width => $term_w, %tabs, join => 0 } );

lib/App/DBBrowser/From/Join.pm  view on Meta::CPAN

            $slave_key =~ s/^-\s//;
            $slave = $ax->qq_table( $sf->{d}{tables_info}{$slave_key} );
        }
        push @{$data->{used_tables}}, $slave; # $slave
        # Alias
        my $slave_alias = $ax->table_alias( $sql, 'tables_in_join', $slave, ++$data->{default_alias} );
        $sql->{join_data}[-1]{table} = $slave . " " . $slave_alias;
        push @{$data->{aliases}}, [ $slave, $slave_alias ];
        ( $data->{col_names}{$slave}, undef ) = $ax->column_names_and_types( $slave . " " . $slave_alias );
        if ( ! defined $data->{col_names}{$slave} ) {
            $sf->__reset_to_backuped_join_data( $sql, $data, $bu_data );
            next SLAVE;
        }
        if ( $sql->{join_data}[-1]{join_type} ne 'CROSS JOIN' ) {
            my $ok = $sf->__add_join_condition( $sql, $data );
            if ( ! $ok ) {
                $sf->__reset_to_backuped_join_data( $sql, $data, $bu_data );
                next SLAVE;
            }
        }
        $ax->print_sql_info( $ax->get_sql_info( $sql ) );
        return 1;
    }
}


sub __reset_to_backuped_join_data {
     my ( $sf, $sql, $data, $bu_data ) = @_;
    $sql->{join_data}[-1] = { join_type => $sql->{join_data}[-1]{join_type} };
    delete @{$data}{ keys %$data };
    # copy by key, so that $data still refers to the original hash:
    for my $key ( keys %$bu_data ) {
        $data->{$key} = $bu_data->{$key};
    }
}


lib/App/DBBrowser/From/Subquery.pm  view on Meta::CPAN

                ( $saved_subqueries, $subquery_history, $print_history ) = $sf->__get_history();
                @queries = $sf->__get_queries( $saved_subqueries, $subquery_history, $print_history );
                $menu = [ @pre, @queries ];
            }
            next SUBQUERY;
        }
        elsif ( $menu->[$idx] eq $readline ) {
            $selected_stmt = '';
        }
        elsif ( $menu->[$idx] eq $build_SQ ) {
            # Don't backup $sf->{d}{default_table_alias_count}
            my $bu_stmt_types = [ @{$sf->{d}{stmt_types}} ];
            my $bu_table_origin = $sf->{d}{table_origin};
            my $bu_main_info = $sf->{d}{main_info};
            $sf->{d}{main_info} = $ext_info || $ax->get_sql_info( $sql );
            $sf->{d}{nested_subqueries}++;
            my $stmt = $sf->__build_SQ( $caller );
            $sf->{d}{nested_subqueries}--;
            $sf->{d}{stmt_types} = $bu_stmt_types;
            $sf->{d}{table_origin} = $bu_table_origin;
            $sf->{d}{main_info} = $bu_main_info;

lib/App/DBBrowser/Table.pm  view on Meta::CPAN

            $changed->{$sub_stmt} = $ret;
        }
        elsif ( $sql->{aggregate_mode} && ! @{$sql->{selected_cols}} ) { ##
            $ax->print_error_message( "No columns selected!", $info );
            next CUSTOMIZE;
        }
        elsif ( $sub_stmt eq $hidden ) {
            if ( ! eval {
                require App::DBBrowser::Table::InsertUpdateDelete;
                my $write = App::DBBrowser::Table::InsertUpdateDelete->new( $sf->{i}, $sf->{o}, $sf->{d} );
                my $backup_sql = $ax->clone_data( $sql );
                $write->table_write_access( $sql );
                for my $key ( keys %$backup_sql ) { ##
                    $sql->{$key} = $backup_sql->{$key};
                }
                1 }
            ) {
                $ax->print_error_message( $@ );
            }
            $sf->{d}{stmt_types} = [ 'Select' ];
            $old_idx = 1;
        }
        elsif ( $sub_stmt eq $return_statement ) {
            my $bu_cte_history = [ @{$sf->{d}{cte_history}} ];



( run in 1.636 second using v1.01-cache-2.11-cpan-49f99fa48dc )