这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 20 additions & 55 deletions mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,14 @@ def get_continuation(width, *_):
def show_suggestion_tip():
return iterations < 2

# Keep track of whether or not the query is mutating. In case
# of a multi-statement query, the overall query is considered
# mutating if any one of the component statements is mutating
mutating = False

def output_res(res, start):
nonlocal mutating
result_count = 0
mutating = False
for title, cur, headers, status in res:
logger.debug("headers: %r", headers)
logger.debug("rows: %r", cur)
Expand All @@ -700,7 +705,14 @@ def output_res(res, start):
else:
max_width = None

formatted = self.format_output(title, cur, headers, special.is_expanded_output(), max_width)
formatted = self.format_output(
title,
cur,
headers,
special.is_expanded_output(),
special.is_redirected(),
max_width,
)

t = time() - start
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this try block, we should probably also restore from the deleted code:

                        if self.beep_after_seconds > 0 and t >= self.beep_after_seconds:
                            self.bell()
                        if special.is_timing_enabled():
                            self.echo("Time: %0.03fs" % t)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed it.

Expand All @@ -710,14 +722,18 @@ def output_res(res, start):
self.output(formatted, status)
except KeyboardInterrupt:
pass
if self.beep_after_seconds > 0 and t >= self.beep_after_seconds:
self.bell()
if special.is_timing_enabled():
self.echo("Time: %0.03fs" % t)
self.echo("Time: %0.03fs" % t)
except KeyboardInterrupt:
pass

start = time()
result_count += 1
mutating = mutating or is_mutating(status)
return mutating
return

def one_iteration(text=None):
if text is None:
Expand Down Expand Up @@ -793,11 +809,6 @@ def one_iteration(text=None):
else:
destroy = True

# Keep track of whether or not the query is mutating. In case
# of a multi-statement query, the overall query is considered
# mutating if any one of the component statements is mutating
mutating = False

try:
logger.debug("sql: %r", text)

Expand All @@ -813,53 +824,7 @@ def one_iteration(text=None):
self.main_formatter.query = text
self.redirect_formatter.query = text
successful = True
result_count = 0
for title, cur, headers, status in res:
logger.debug("headers: %r", headers)
logger.debug("rows: %r", cur)
logger.debug("status: %r", status)
threshold = 1000
if is_select(status) and cur and cur.rowcount > threshold:
self.echo("The result set has more than {} rows.".format(threshold), fg="red")
if not confirm("Do you want to continue?"):
self.echo("Aborted!", err=True, fg="red")
break

if self.auto_vertical_output:
max_width = self.prompt_app.output.get_size().columns
else:
max_width = None

if special.forced_horizontal():
max_width = None

formatted = self.format_output(
title,
cur,
headers,
special.is_expanded_output(),
special.is_redirected(),
max_width,
)

t = time() - start
try:
if result_count > 0:
self.echo("")
try:
self.output(formatted, status)
except KeyboardInterrupt:
pass
if self.beep_after_seconds > 0 and t >= self.beep_after_seconds:
self.bell()
if special.is_timing_enabled():
self.echo("Time: %0.03fs" % t)
except KeyboardInterrupt:
pass

start = time()
result_count += 1
mutating = mutating or destroy or is_mutating(status)
output_res(res, start)
special.unset_once_if_written(self.post_redirect_command)
special.flush_pipe_once_if_written(self.post_redirect_command)
except EOFError as e:
Expand Down