Skip to content

Commit

Permalink
fixed regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
gfrlv committed Oct 9, 2019
1 parent c092546 commit 848741a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mycli/clibuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _multiline_exception(text):
text.lower().startswith('delimiter') or

# Ended with the current delimiter (usually a semi-column)
text.endswith(str(special.delimiter)) or
text.endswith(special.delimiter.current) or

text.endswith('\\g') or
text.endswith('\\G') or
Expand Down
2 changes: 1 addition & 1 deletion mycli/clitoolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_toolbar_tokens():
result.append(('class:bottom-toolbar', ' '))

if mycli.multi_line:
delimiter = str(special.delimiter)
delimiter = special.delimiter.current
result.append(
(
'class:bottom-toolbar',
Expand Down
9 changes: 5 additions & 4 deletions mycli/packages/special/delimitercommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class DelimiterCommand(object):
def __init__(self):
self._delimiter = ';'

def _split(self, sql):
"""Temporary workaround until sqlparse.split() learns about custom
delimiters."""
Expand Down Expand Up @@ -45,10 +45,10 @@ def queries_iter(self, input):
sql = sql.strip(delimiter)
else:
trailing_delimiter = False

yield sql

# if the delimiter was changed by the last command,
# if the delimiter was changed by the last command,
# re-split everything, and if we previously stripped
# the delimiter, append it to the end
if self._delimiter != delimiter:
Expand Down Expand Up @@ -78,5 +78,6 @@ def set(self, arg, **_):
self._delimiter = delimiter
return [(None, None, None, "Changed delimiter to {}".format(delimiter))]

def __str__(self):
@property
def current(self):
return self._delimiter
2 changes: 2 additions & 0 deletions mycli/sqlexecute.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

import logging
import pymysql
import sqlparse
Expand Down
9 changes: 8 additions & 1 deletion test/test_special_iocommands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# coding: utf-8
from __future__ import unicode_literals

import os
import stat
import tempfile
Expand Down Expand Up @@ -267,4 +269,9 @@ def test_set_delimiter():
delimiter = mycli.packages.special.delimiter
for delim in ('foo', 'bar'):
delimiter.set(delim)
assert str(delimiter) == delim
assert delimiter.current == delim


def teardown_function():
delimiter = mycli.packages.special.delimiter
delimiter.set(';')

0 comments on commit 848741a

Please sign in to comment.