mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure auto-complete works for objects in schemas other than public and pg_catalog. Fixes #3630
This commit is contained in:
@@ -22,6 +22,8 @@ class QueryToolAutoCompleteFeatureTest(BaseFeatureTest):
|
||||
This feature test will test the query tool auto complete feature.
|
||||
"""
|
||||
|
||||
first_schema_name = ""
|
||||
second_schema_name = ""
|
||||
first_table_name = ""
|
||||
second_table_name = ""
|
||||
|
||||
@@ -33,6 +35,17 @@ class QueryToolAutoCompleteFeatureTest(BaseFeatureTest):
|
||||
self.page.wait_for_spinner_to_disappear()
|
||||
|
||||
self.page.add_server(self.server)
|
||||
|
||||
self.first_schema_name = "test_schema" + \
|
||||
str(random.randint(1000, 3000))
|
||||
test_utils.create_schema(self.server, self.test_db,
|
||||
self.first_schema_name)
|
||||
|
||||
self.second_schema_name = "comp_schema" + \
|
||||
str(random.randint(1000, 3000))
|
||||
test_utils.create_schema(self.server, self.test_db,
|
||||
self.second_schema_name)
|
||||
|
||||
self.first_table_name = "auto_comp_" + \
|
||||
str(random.randint(1000, 3000))
|
||||
test_utils.create_table(self.server, self.test_db,
|
||||
@@ -87,6 +100,18 @@ class QueryToolAutoCompleteFeatureTest(BaseFeatureTest):
|
||||
print("OK.", file=sys.stderr)
|
||||
self._clear_query_tool()
|
||||
|
||||
print("Auto complete schema other than default start with test_ ... ",
|
||||
file=sys.stderr, end="")
|
||||
self._auto_complete("SELECT * FROM te", self.first_schema_name)
|
||||
print("OK.", file=sys.stderr)
|
||||
self._clear_query_tool()
|
||||
|
||||
print("Auto complete schema other than default starts with comp_ ... ",
|
||||
file=sys.stderr, end="")
|
||||
self._auto_complete("SELECT * FROM co", self.second_schema_name)
|
||||
print("OK.", file=sys.stderr)
|
||||
self._clear_query_tool()
|
||||
|
||||
print("Auto complete first table in public schema ... ",
|
||||
file=sys.stderr, end="")
|
||||
self._auto_complete("SELECT * FROM public.", self.first_table_name)
|
||||
|
||||
@@ -116,16 +116,22 @@ class SQLAutoComplete(object):
|
||||
|
||||
self.search_path = []
|
||||
schema_names = []
|
||||
# Fetch the search path
|
||||
if self.conn.connected():
|
||||
# Fetch the search path
|
||||
query = render_template(
|
||||
"/".join([self.sql_path, 'schema.sql']), search_path=True)
|
||||
status, res = self.conn.execute_dict(query)
|
||||
if status:
|
||||
for record in res['rows']:
|
||||
schema_names.append(record['schema'])
|
||||
self.search_path.append(record['schema'])
|
||||
|
||||
# Fetch the schema names
|
||||
query = render_template("/".join([self.sql_path, 'schema.sql']))
|
||||
status, res = self.conn.execute_dict(query)
|
||||
if status:
|
||||
for record in res['rows']:
|
||||
schema_names.append(record['schema'])
|
||||
|
||||
pref = Preferences.module('sqleditor')
|
||||
keywords_in_uppercase = \
|
||||
pref.preference('keywords_in_uppercase').get()
|
||||
|
||||
Reference in New Issue
Block a user