| 1 | package # hide from PAUSE | ||
| 2 | App::DBBrowser::Options::Defaults; | ||
| 3 | |||
| 4 | use warnings; | ||
| 5 | use strict; | ||
| 6 | use 5.016; | ||
| 7 | |||
| 8 | use App::DBBrowser::Auxil; | ||
| 9 | |||
| 10 | |||
| 11 | sub new { | ||
| 12 | my ( $class, $info, $options ) = @_; | ||
| 13 | bless { | ||
| 14 | i => $info, | ||
| 15 | o => $options, | ||
| 16 | }, $class; | ||
| 17 | } | ||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | sub defaults_pre_plugin { | ||
| 22 | my ( $sf ) = @_; | ||
| 23 | my $defaults_pre_plugin = { | ||
| 24 | G => { | ||
| 25 | menu_memory => 1, | ||
| 26 | plugins => [ 'SQLite' ], | ||
| 27 | }, | ||
| 28 | table => { | ||
| 29 | mouse => 0, | ||
| 30 | }, | ||
| 31 | # could be more | ||
| 32 | }; | ||
| 33 | return $defaults_pre_plugin; | ||
| 34 | } | ||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | sub defaults { | ||
| 39 | my ( $sf, $driver ) = @_; | ||
| 40 | my $defaults = { | ||
| 41 | G => { | ||
| 42 | base_indent => 1, | ||
| 43 | file_find_warnings => 0, | ||
| 44 | warnings_table_print => 1, | ||
| 45 | metadata => 0, | ||
| 46 | operators => [ " = ", " != ", " < ", " > ", "REGEXP_i", "NOT REGEXP_i", "IS NULL", "IS NOT NULL", "IN", "NOT IN" ], | ||
| 47 | |||
| 48 | qualified_table_name => 0, | ||
| 49 | quote_tables => 0, | ||
| 50 | quote_columns => 0, | ||
| 51 | |||
| 52 | edit_sql_menu_sq => 0, ## | ||
| 53 | pg_autocast => 1, | ||
| 54 | |||
| 55 | db2_encoding => 'utf8', | ||
| 56 | duckdb_utf8_decode => 1, | ||
| 57 | }, | ||
| 58 | alias => { | ||
| 59 | complex_cols_select => 0, | ||
| 60 | tables_in_join => 1, | ||
| 61 | join_columns => 0, | ||
| 62 | derived_table => 1, | ||
| 63 | ordinary_table => 0, | ||
| 64 | |||
| 65 | use_in_group_by => 0, # if SQLite, MySQL, MariaDB, Pg, Firebird, Informix, Oracle >= 23ai | ||
| 66 | use_in_having => 0, # if SQLite, MySQL, MariaDB, Oracle >= 23ai | ||
| 67 | use_in_order_by => 1, | ||
| 68 | }, | ||
| 69 | enable => { | ||
| 70 | create_table => 0, | ||
| 71 | drop_table => 0, | ||
| 72 | create_view => 0, | ||
| 73 | drop_view => 0, | ||
| 74 | |||
| 75 | insert_into => 0, | ||
| 76 | update => 0, | ||
| 77 | delete => 0, | ||
| 78 | |||
| 79 | extended_cols => 1, | ||
| 80 | extended_values => 0, | ||
| 81 | extended_args => 0, | ||
| 82 | |||
| 83 | m_derived => 0, | ||
| 84 | m_cte => 0, | ||
| 85 | |||
| 86 | join => 0, | ||
| 87 | union => 0, | ||
| 88 | |||
| 89 | j_derived => 0, | ||
| 90 | j_cte => 0, | ||
| 91 | |||
| 92 | u_derived => 0, | ||
| 93 | u_cte => 0, | ||
| 94 | u_edit_stmt => 0, | ||
| 95 | u_parentheses => 0, | ||
| 96 | }, | ||
| 97 | table => { | ||
| 98 | choose_columns => 0, # not an option, always 0 | ||
| 99 | codepage_mapping => 0, # not an option, always 0 | ||
| 100 | hide_cursor => 0, # not an option, always 0 | ||
| 101 | max_rows => 0, # not an option, always 0 | ||
| 102 | page => 2, # not an option, always 2 | ||
| 103 | |||
| 104 | binary_filter => 0, | ||
| 105 | binary_string => 'BNRY', | ||
| 106 | color => 0, | ||
| 107 | col_trim_threshold => 30, | ||
| 108 | expanded_line_spacing => 1, | ||
| 109 | expanded_max_width => 0, | ||
| 110 | # mouse => 0, | ||
| 111 | pad_row_edges => 0, | ||
| 112 | progress_bar => 60_000, | ||
| 113 | search => 1, | ||
| 114 | squash_spaces => 0, | ||
| 115 | tab_width => 2, | ||
| 116 | table_expand => 1, # expand_table_rows ## | ||
| 117 | trunc_fract_first => 1, | ||
| 118 | undef => '', | ||
| 119 | }, | ||
| 120 | insert => { | ||
| 121 | file_encoding => 'UTF-8', | ||
| 122 | history_dirs => 4, | ||
| 123 | parse_mode_input_file => 0, | ||
| 124 | enable_input_filter => 1, | ||
| 125 | empty_to_null_plain => 1, | ||
| 126 | empty_to_null_file => 1, | ||
| 127 | data_source_create_table => 2, | ||
| 128 | data_source_insert => 2, | ||
| 129 | max_cols_plain => 25, | ||
| 130 | show_hidden_files => 0, | ||
| 131 | file_filter => '', | ||
| 132 | }, | ||
| 133 | create => { | ||
| 134 | default_ai_column_name => 'Id', | ||
| 135 | option_ai_column_enabled => 0, | ||
| 136 | data_type_guessing => 1, | ||
| 137 | encode_for_data_type_guessing => 0, | ||
| 138 | table_constraint_rows => 0, | ||
| 139 | table_option_rows => 0, | ||
| 140 | view_name_prefix => '', | ||
| 141 | }, | ||
| 142 | split => { | ||
| 143 | record_sep => '\n', | ||
| 144 | record_l_trim => '', | ||
| 145 | record_r_trim => '', | ||
| 146 | field_sep => ',', | ||
| 147 | field_l_trim => '\s+', | ||
| 148 | field_r_trim => '\s+', | ||
| 149 | }, | ||
| 150 | csv_in => { | ||
| 151 | auto_diag => 1, # not an option, always 1 | ||
| 152 | |||
| 153 | sep_char => ',', | ||
| 154 | quote_char => '"', | ||
| 155 | escape_char => '"', | ||
| 156 | eol => '', | ||
| 157 | comment_str => '', | ||
| 158 | |||
| 159 | allow_loose_escapes => 0, | ||
| 160 | allow_loose_quotes => 0, | ||
| 161 | allow_whitespace => 0, | ||
| 162 | blank_is_undef => 1, | ||
| 163 | binary => 1, | ||
| 164 | decode_utf8 => 1, | ||
| 165 | empty_is_undef => 0, | ||
| 166 | skip_empty_rows => 0, | ||
| 167 | }, | ||
| 168 | export => { | ||
| 169 | export_dir => $sf->{i}{home_dir}, | ||
| 170 | add_extension => 0, | ||
| 171 | default_filename => 0, | ||
| 172 | file_encoding => 'UTF-8', | ||
| 173 | }, | ||
| 174 | csv_out => { | ||
| 175 | auto_diag => 1, # not an option, always 1 | ||
| 176 | |||
| 177 | sep_char => ',', | ||
| 178 | quote_char => '"', | ||
| 179 | escape_char => '"', | ||
| 180 | eol => '', | ||
| 181 | undef_str => '', | ||
| 182 | |||
| 183 | always_quote => 0, | ||
| 184 | binary => 1, | ||
| 185 | escape_null => 1, | ||
| 186 | quote_binary => 1, | ||
| 187 | quote_empty => 0, | ||
| 188 | quote_space => 1, | ||
| 189 | }, | ||
| 190 | connect_data => { | ||
| 191 | host_required => 1, | ||
| 192 | port_required => 1, | ||
| 193 | user_required => 1, | ||
| 194 | pass_required => 1, | ||
| 195 | host => '', | ||
| 196 | port => '', | ||
| 197 | user => '', | ||
| 198 | use_dbi_host => 0, | ||
| 199 | use_dbi_port => 0, | ||
| 200 | use_dbi_user => 0, | ||
| 201 | use_dbi_pass => 0, | ||
| 202 | }, | ||
| 203 | connect_attr => { | ||
| 204 | ChopBlanks => 0, | ||
| 205 | LongTruncOk => 0, | ||
| 206 | LongReadLen => 80, | ||
| 207 | }, | ||
| 208 | }; | ||
| 209 | if ( $driver eq 'SQLite' ) { | ||
| 210 | $defaults->{connect_attr}{sqlite_see_if_its_a_number} = 1; | ||
| 211 | $defaults->{connect_attr}{sqlite_string_mode} = 5; | ||
| 212 | $defaults->{connect_attr}{sqlite_busy_timeout} = 30000; | ||
| 213 | } | ||
| 214 | elsif ( $driver eq 'mysql' ) { | ||
| 215 | $defaults->{connect_attr}{mysql_enable_utf8} = 0; | ||
| 216 | $defaults->{connect_attr}{mysql_enable_utf8mb4} = 1; | ||
| 217 | $defaults->{connect_attr}{mysql_bind_type_guessing} = 1; | ||
| 218 | } | ||
| 219 | elsif ( $driver eq 'MariaDB' ) { | ||
| 220 | $defaults->{connect_attr}{mariadb_bind_type_guessing} = 1; | ||
| 221 | } | ||
| 222 | elsif ( $driver eq 'Pg' ) { | ||
| 223 | $defaults->{connect_attr}{pg_enable_utf8} = -1; | ||
| 224 | } | ||
| 225 | elsif ( $driver eq 'Firebird' ) { | ||
| 226 | $defaults->{connect_attr}{ib_enable_utf8} = 1; | ||
| 227 | $defaults->{connect_attr}{ib_dialect} = ''; | ||
| 228 | $defaults->{connect_attr}{ib_role} = ''; | ||
| 229 | $defaults->{connect_attr}{ib_charset} = 'UTF8'; | ||
| 230 | } | ||
| 231 | elsif ( $driver eq 'Oracle' ) { | ||
| 232 | $defaults->{connect_attr}{ora_charset} = 'AL32UTF8'; | ||
| 233 | $defaults->{connect_attr}{AskIfSID} = 0; | ||
| 234 | } | ||
| 235 | elsif ( $driver eq 'DB2' ) { | ||
| 236 | } | ||
| 237 | elsif ( $driver eq 'Informix' ) { | ||
| 238 | $defaults->{connect_attr}{ix_EnableUTF8} = 1; | ||
| 239 | } | ||
| 240 | elsif ( $driver eq 'ODBC' ) { | ||
| 241 | $defaults->{connect_attr}{odbc_utf8_on} = 0; | ||
| 242 | $defaults->{connect_attr}{odbc_ignore_named_placeholders} = 0; | ||
| 243 | #$defaults->{connect_attr}{odbc_array_operations} = 0; | ||
| 244 | $defaults->{connect_attr}{odbc_batch_size} = 10; | ||
| 245 | } | ||
| 246 | elsif ( $driver eq 'DuckDB' ) { | ||
| 247 | } | ||
| 248 | return $defaults; | ||
| 249 | } | ||
| 250 | |||
| 251 | |||
| 252 | |||
| 253 | |||
| 254 | |||
| 255 | 1; | ||
| 256 | |||
| 257 | |||
| 258 | __END__ |