1
0
Fork 0

Adding upstream version 1.6.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-09 17:41:57 +01:00
parent 0912fc1528
commit ec905d2958
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: repos:
- repo: https://github.com/ambv/black - repo: https://github.com/ambv/black
rev: stable rev: 20.8b1
hooks: hooks:
- id: black - id: black
language_version: python3.7 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 ## Unreleased - TBD
<!-- add upcoming change notes here --> ### Features
### Bug Fixes
## 1.6.0 - 2021-03-15
### Features ### Features
- Add verbose feature to `favorite_query` command. (Thanks: [Zhaolong Zhu]) - Add verbose feature to `favorite_query` command. (Thanks: [Zhaolong Zhu])
- `\f query` does not show the full SQL. - `\f query` does not show the full SQL.
- `\f+ query` shows the full SQL. - `\f+ query` shows the full SQL.
- Add prompt format of file's basename. (Thanks: [elig0n])
### Bug Fixes ### Bug Fixes
- Fix compatibility with sqlparse >= 0.4.0. (Thanks: [chocolateboy]) - Fix compatibility with sqlparse >= 0.4.0. (Thanks: [chocolateboy])
- Fix invalid utf-8 exception. (Thanks: [Amjith])
## 1.4.1 - 2020-07-27 ## 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 # litecli prompt
# \D - The full current date # \D - The full current date
# \d - Database name # \d - Database name
# \f - File basename of the "main" database
# \m - Minutes of the current time # \m - Minutes of the current time
# \n - Newline # \n - Newline
# \P - AM/PM # \P - AM/PM

View file

@ -704,8 +704,7 @@ class LiteCli(object):
] ]
def _on_completions_refreshed(self, new_completer): 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: with self._completer_lock:
self.completer = new_completer self.completer = new_completer
@ -725,6 +724,7 @@ class LiteCli(object):
sqlexecute = self.sqlexecute sqlexecute = self.sqlexecute
now = datetime.now() now = datetime.now()
string = string.replace("\\d", sqlexecute.dbname or "(none)") 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("\\n", "\n")
string = string.replace("\\D", now.strftime("%a %b %d %H:%M:%S %Y")) string = string.replace("\\D", now.strftime("%a %b %d %H:%M:%S %Y"))
string = string.replace("\\m", now.strftime("%M")) string = string.replace("\\m", now.strftime("%M"))

View file

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

View file

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

View file

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

View file

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

View file

@ -54,6 +54,7 @@ wider_completion_menu = False
# litecli prompt # litecli prompt
# \D - The full current date # \D - The full current date
# \d - Database name # \d - Database name
# \f - File basename of the "main" database
# \m - Minutes of the current time # \m - Minutes of the current time
# \n - Newline # \n - Newline
# \P - AM/PM # \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 " "SELECT * FROM sch.tabl ORDER BY ", "SELECT * FROM sch.tabl ORDER BY "
) )
assert sorted_dicts(suggestions) == sorted_dicts( 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 Document(text=text, cursor_position=position), complete_event
) )
) )
assert result == [ assert (
result
== [
Completion(text="*", start_position=0), Completion(text="*", start_position=0),
Completion(text="`ABC`", start_position=0), Completion(text="`ABC`", start_position=0),
Completion(text="`insert`", start_position=0), Completion(text="`insert`", start_position=0),
Completion(text="id", start_position=0), Completion(text="id", start_position=0),
] + list(map(Completion, completer.functions)) + [ ]
Completion(text="`select`", start_position=0) + list(map(Completion, completer.functions))
] + list( + [Completion(text="`select`", start_position=0)]
map(Completion, sorted(completer.keywords)) + 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"é",)]) 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 @dbtest
def test_multiple_queries_same_line(executor): def test_multiple_queries_same_line(executor):
results = run(executor, "select 'foo'; select 'bar'") results = run(executor, "select 'foo'; select 'bar'")
@ -186,6 +197,7 @@ def test_bind_parameterized_favorite_query(executor):
with pytest.raises(ProgrammingError): with pytest.raises(ProgrammingError):
results = run(executor, "\\f+ q_param 1 2") results = run(executor, "\\f+ q_param 1 2")
@dbtest @dbtest
def test_verbose_feature_of_favorite_query(executor): def test_verbose_feature_of_favorite_query(executor):
set_expanded_output(False) set_expanded_output(False)
@ -198,11 +210,7 @@ def test_verbose_feature_of_favorite_query(executor):
results = run(executor, "\\f sh_param 1") results = run(executor, "\\f sh_param 1")
assert_result_equal( assert_result_equal(
results, results, title=None, headers=["a", "id"], rows=[("abc", 1)], auto_status=False,
title=None,
headers=["a", "id"],
rows=[("abc", 1)],
auto_status=False,
) )
results = run(executor, "\\f+ sh_param 1") results = run(executor, "\\f+ sh_param 1")
@ -214,6 +222,7 @@ def test_verbose_feature_of_favorite_query(executor):
auto_status=False, auto_status=False,
) )
@dbtest @dbtest
def test_shell_parameterized_favorite_query(executor): def test_shell_parameterized_favorite_query(executor):
set_expanded_output(False) set_expanded_output(False)