diff --git a/changelog.md b/changelog.md index de0ac40b..5231d30d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,11 @@ +Upcoming (TBD) +============== + +Features +--------- +* Let `help ` list similar keywords when not found. + + 1.57.0 (2026/02/25) ============== diff --git a/mycli/packages/special/main.py b/mycli/packages/special/main.py index bcab3ed6..01b22d62 100644 --- a/mycli/packages/special/main.py +++ b/mycli/packages/special/main.py @@ -170,20 +170,25 @@ def show_help(*_args) -> list[SQLResult]: def show_keyword_help(cur: Cursor, arg: str) -> list[SQLResult]: """ - Call the built-in "show ", to display help for an SQL keyword. + Call the built-in "show ", to display help for an SQL keyword. :param cur: cursor :param arg: string :return: list """ - keyword = arg.strip('"').strip("'") - query = f"help '{keyword}'" + keyword = arg.strip().strip('"\'') + query = 'help %s' logger.debug(query) - cur.execute(query) + cur.execute(query, keyword) if cur.description and cur.rowcount > 0: headers = [x[0] for x in cur.description] - return [SQLResult(results=cur, headers=headers, status="")] + return [SQLResult(results=cur, headers=headers)] + logger.debug(query) + cur.execute(query, (f'%{keyword}%',)) + if cur.description and cur.rowcount > 0: + headers = [x[0] for x in cur.description] + return [SQLResult(title='Similar terms:', results=cur, headers=headers)] else: - return [SQLResult(status=f'No help found for {keyword}.')] + return [SQLResult(status=f'No help found for "{keyword}".')] @special_command("exit", "exit", "Exit.", arg_type=ArgType.NO_QUERY, aliases=["\\q"])