diff --git a/db_sql_autocomplete.php b/db_sql_autocomplete.php index 4897f0058a..3be88c43ca 100644 --- a/db_sql_autocomplete.php +++ b/db_sql_autocomplete.php @@ -8,17 +8,19 @@ require_once 'libraries/common.inc.php'; -$db = isset($_POST['db']) ? $_POST['db'] : $GLOBALS['db']; -$sql_autocomplete = array(); - -if ($db) { - $tableNames = $GLOBALS['dbi']->getTables($db); - foreach ($tableNames as $tableName) { - $sql_autocomplete[$tableName] = $GLOBALS['dbi']->getColumns( - $db, $tableName - ); +if ($GLOBALS['cfg']['EnableAutocompleteForTablesAndColumns']) { + $db = isset($_POST['db']) ? $_POST['db'] : $GLOBALS['db']; + $sql_autocomplete = array(); + if ($db) { + $tableNames = $GLOBALS['dbi']->getTables($db); + foreach ($tableNames as $tableName) { + $sql_autocomplete[$tableName] = $GLOBALS['dbi']->getColumns( + $db, $tableName + ); + } } +} else { + $sql_autocomplete = true; } - $response = PMA_Response::getInstance(); $response->addJSON("tables", json_encode($sql_autocomplete)); diff --git a/doc/config.rst b/doc/config.rst index 237df7f45a..472bca7a8e 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -2435,6 +2435,14 @@ Text fields Defines if the whole textarea of the query box will be selected on click. +.. config:option:: $cfg['EnableAutocompleteForTablesAndColumns'] + + :type: boolean + :default: true + + Whether to Enable Autocomplete for table and Column names in any + SQL Query box. + SQL query box settings ---------------------- diff --git a/libraries/config.default.php b/libraries/config.default.php index e2db43abde..78d82810b7 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -2875,6 +2875,13 @@ $cfg['SQLQuery']['ShowAsPHP'] = true; */ $cfg['SQLQuery']['Refresh'] = true; +/** + * Enables AutoComplete for table & Column names in SQL queries + * + * default = 'true' + */ +$cfg['EnableAutocompleteForTablesAndColumns'] = true; + /******************************************************************************* * Web server upload/save/import directories diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php index 4b04dc5bc4..10ce83827b 100644 --- a/libraries/config/messages.inc.php +++ b/libraries/config/messages.inc.php @@ -91,6 +91,8 @@ $strConfigDefaultTabServer_desc = __('Tab that is displayed when entering a serv $strConfigDefaultTabServer_name = __('Default server tab'); $strConfigDefaultTabTable_desc = __('Tab that is displayed when entering a table.'); $strConfigDefaultTabTable_name = __('Default table tab'); +$strConfigEnableAutocompleteForTablesAndColumns_desc = __('Auto-Complete of the table and Column names in the SQL queries.'); +$strConfigEnableAutocompleteForTablesAndColumns_name = __('Enable AutoComplete for Table '); $strConfigHideStructureActions_desc = __('Whether the table structure actions should be hidden.'); $strConfigHideStructureActions_name = __('Hide table structure actions'); diff --git a/libraries/config/setup.forms.php b/libraries/config/setup.forms.php index 34b1180d38..ead911d790 100644 --- a/libraries/config/setup.forms.php +++ b/libraries/config/setup.forms.php @@ -159,7 +159,8 @@ $forms['Sql_queries']['Sql_queries'] = array( 'IgnoreMultiSubmitErrors', 'MaxCharactersInDisplayedSQL', 'RetainQueryBox', - 'CodemirrorEnable'); + 'CodemirrorEnable', + 'EnableAutocompleteForTablesAndColumns'); $forms['Sql_queries']['Sql_box'] = array('SQLQuery' => array( 'Edit', 'Explain', diff --git a/libraries/config/user_preferences.forms.php b/libraries/config/user_preferences.forms.php index f6b63a92fb..56b5118015 100644 --- a/libraries/config/user_preferences.forms.php +++ b/libraries/config/user_preferences.forms.php @@ -68,7 +68,8 @@ $forms['Sql_queries']['Sql_queries'] = array( 'IgnoreMultiSubmitErrors', 'MaxCharactersInDisplayedSQL', 'RetainQueryBox', - 'CodemirrorEnable'); + 'CodemirrorEnable', + 'EnableAutocompleteForTablesAndColumns'); $forms['Sql_queries']['Sql_box'] = array( 'SQLQuery/Edit', 'SQLQuery/Explain',