1
0
Fork 0

Merging upstream version 1.6.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 17:42:20 +01:00
parent 4b3dd727fd
commit 12edc19d72
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
17 changed files with 95 additions and 53 deletions

2
.git-blame-ignore-revs Normal file
View file

@ -0,0 +1,2 @@
# Black
f767afc80bd5bcc8f1b1cc1a134babc2dec4d239

44
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,44 @@
name: litecli
on:
pull_request:
paths-ignore:
- '**.md'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements
run: |
python -m pip install -U pip setuptools
pip install --no-cache-dir -e .
pip install -r requirements-dev.txt -U --upgrade-strategy=only-if-needed
- name: Run unit tests
env:
PYTEST_PASSWORD: root
run: |
./setup.py test --pytest-args="--cov-report= --cov=litecli"
- name: Run Black
run: |
./setup.py lint
if: matrix.python-version == '3.6'
- name: Coverage
run: |
coverage report
codecov

View file

@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: stable
rev: 20.8b1
hooks:
- id: black
language_version: python3.7

View file

@ -1,29 +0,0 @@
language: python
python:
- "3.6"
matrix:
include:
- python: 3.7
dist: xenial
sudo: true
install:
- pip install -r requirements-dev.txt
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then pip install black; fi
- pip install -e .
script:
- ./setup.py test --pytest-args="--cov-report= --cov=litecli"
- coverage report
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then ./setup.py lint; fi
after_success:
- codecov
notifications:
webhooks:
urls:
- YOUR_WEBHOOK_URL
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always

View file

@ -1,16 +1,23 @@
## Unreleased - TBD
<!-- add upcoming change notes here -->
### Features
### Bug Fixes
## 1.6.0 - 2021-03-15
### Features
- Add verbose feature to `favorite_query` command. (Thanks: [Zhaolong Zhu])
- `\f query` does not show the full SQL.
- `\f+ query` shows the full SQL.
- Add prompt format of file's basename. (Thanks: [elig0n])
### Bug Fixes
- Fix compatibility with sqlparse >= 0.4.0. (Thanks: [chocolateboy])
- Fix invalid utf-8 exception. (Thanks: [Amjith])
## 1.4.1 - 2020-07-27

View file

@ -1 +1 @@
__version__ = "1.5.0"
__version__ = "1.6.0"

View file

@ -55,6 +55,7 @@ wider_completion_menu = False
# litecli prompt
# \D - The full current date
# \d - Database name
# \f - File basename of the "main" database
# \m - Minutes of the current time
# \n - Newline
# \P - AM/PM

View file

@ -704,8 +704,7 @@ class LiteCli(object):
]
def _on_completions_refreshed(self, new_completer):
"""Swap the completer object in cli with the newly created completer.
"""
"""Swap the completer object in cli with the newly created completer."""
with self._completer_lock:
self.completer = new_completer
@ -725,6 +724,7 @@ class LiteCli(object):
sqlexecute = self.sqlexecute
now = datetime.now()
string = string.replace("\\d", sqlexecute.dbname or "(none)")
string = string.replace("\\f", os.path.basename(sqlexecute.dbname or "(none)"))
string = string.replace("\\n", "\n")
string = string.replace("\\D", now.strftime("%a %b %d %H:%M:%S %Y"))
string = string.replace("\\m", now.strftime("%M"))

View file

@ -166,7 +166,7 @@ def extract_tables(sql):
def find_prev_keyword(sql):
""" Find the last sql keyword in an SQL statement
"""Find the last sql keyword in an SQL statement
Returns the value of the last keyword, and the text of the query with
everything after the last keyword stripped

View file

@ -276,8 +276,7 @@ def save_favorite_query(arg, **_):
@special_command("\\fd", "\\fd [name]", "Delete a favorite query.")
def delete_favorite_query(arg, **_):
"""Delete an existing favorite query.
"""
"""Delete an existing favorite query."""
usage = "Syntax: \\fd name.\n\n" + favoritequeries.usage
if not arg:
return [(None, None, None, usage)]

View file

@ -61,6 +61,7 @@ class SQLExecute(object):
raise Exception("Path does not exist: {}".format(db_dir_name))
conn = sqlite3.connect(database=db_name, isolation_level=None)
conn.text_factory = lambda x: x.decode("utf-8", "backslashreplace")
if self.conn:
self.conn.close()

View file

@ -7,3 +7,4 @@ pexpect
coverage
codecov
click
black

View file

@ -83,7 +83,9 @@ class test(TestCommand):
self.pytest_args = ""
def run_tests(self):
unit_test_errno = subprocess.call("pytest " + self.pytest_args, shell=True)
unit_test_errno = subprocess.call(
"pytest tests " + self.pytest_args, shell=True
)
# cli_errno = subprocess.call('behave test/features', shell=True)
# sys.exit(unit_test_errno or cli_errno)
sys.exit(unit_test_errno)

View file

@ -54,6 +54,7 @@ wider_completion_menu = False
# litecli prompt
# \D - The full current date
# \d - Database name
# \f - File basename of the "main" database
# \m - Minutes of the current time
# \n - Newline
# \P - AM/PM

View file

@ -36,7 +36,9 @@ def test_order_by_suggests_cols_with_qualified_table_scope():
"SELECT * FROM sch.tabl ORDER BY ", "SELECT * FROM sch.tabl ORDER BY "
)
assert sorted_dicts(suggestions) == sorted_dicts(
[{"type": "column", "tables": [("sch", "tabl", None)]},]
[
{"type": "column", "tables": [("sch", "tabl", None)]},
]
)

View file

@ -367,15 +367,17 @@ def test_auto_escaped_col_names(completer, complete_event):
Document(text=text, cursor_position=position), complete_event
)
)
assert result == [
assert (
result
== [
Completion(text="*", start_position=0),
Completion(text="`ABC`", start_position=0),
Completion(text="`insert`", start_position=0),
Completion(text="id", start_position=0),
] + list(map(Completion, completer.functions)) + [
Completion(text="`select`", start_position=0)
] + list(
map(Completion, sorted(completer.keywords))
]
+ list(map(Completion, completer.functions))
+ [Completion(text="`select`", start_position=0)]
+ list(map(Completion, sorted(completer.keywords)))
)

View file

@ -101,6 +101,17 @@ def test_unicode_support_in_output(executor):
assert_result_equal(results, headers=["t"], rows=[(u"é",)])
@dbtest
def test_invalid_unicode_values_dont_choke(executor):
run(executor, "create table unicodechars(t text)")
# \xc3 is not a valid utf-8 char. But we can insert it into the database
# which can break querying if not handled correctly.
run(executor, u"insert into unicodechars (t) values (cast(x'c3' as text))")
results = run(executor, u"select * from unicodechars")
assert_result_equal(results, headers=["t"], rows=[("\\xc3",)])
@dbtest
def test_multiple_queries_same_line(executor):
results = run(executor, "select 'foo'; select 'bar'")
@ -186,6 +197,7 @@ def test_bind_parameterized_favorite_query(executor):
with pytest.raises(ProgrammingError):
results = run(executor, "\\f+ q_param 1 2")
@dbtest
def test_verbose_feature_of_favorite_query(executor):
set_expanded_output(False)
@ -198,11 +210,7 @@ def test_verbose_feature_of_favorite_query(executor):
results = run(executor, "\\f sh_param 1")
assert_result_equal(
results,
title=None,
headers=["a", "id"],
rows=[("abc", 1)],
auto_status=False,
results, title=None, headers=["a", "id"], rows=[("abc", 1)], auto_status=False,
)
results = run(executor, "\\f+ sh_param 1")
@ -214,6 +222,7 @@ def test_verbose_feature_of_favorite_query(executor):
auto_status=False,
)
@dbtest
def test_shell_parameterized_favorite_query(executor):
set_expanded_output(False)