Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.6.12 #294

Merged
merged 4 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.6.11
current_version = 0.6.12
commit = True
tag = True
message = 🔖 Bump version: {current_version} → {new_version}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ repos:
hooks:
- id: pyproject-flake8
additional_dependencies: [ flake8-bugbear ]
args: [ "--extend-ignore", "E203, E501" ]
args: [ "--extend-ignore", "E203, E501, W503" ]
exclude: (test_[\w]+\.py|\.csv|\.json|\.lock)$

- repo: https://github.com/codespell-project/codespell
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.11
0.6.12
2 changes: 1 addition & 1 deletion ftmq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ftmq.query import Query

__version__ = "0.6.11"
__version__ = "0.6.12"
__all__ = ["Query"]
14 changes: 9 additions & 5 deletions ftmq/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,15 @@ def all_canonical_ids(self) -> Select:

@cached_property
def _unsorted_statements(self) -> Select:
return (
select(self.table)
.where(self.table.c.canonical_id.in_(self.canonical_ids))
.order_by(self.table.c.canonical_id)
)
where = self.clause
if (
self.q.properties
or self.q.reversed
or self.q.search_filters
or self.q.limit
):
where = self.table.c.canonical_id.in_(self.canonical_ids)
return select(self.table).where(where).order_by(self.table.c.canonical_id)

@cached_property
def _sorted_statements(self) -> Select:
Expand Down
3 changes: 3 additions & 0 deletions ftmq/store/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def __init__(
else:
dataset = DefaultDataset
super().__init__(dataset=dataset, linker=linker or Resolver(), **kwargs)
# implicit set all datasets as store scope:
if dataset == DefaultDataset:
self.dataset = self.get_catalog().get_scope()

def get_catalog(self) -> C:
# return implicit catalog computed from current datasets in store
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@investigativedata/ftmq",
"version": "0.6.11",
"version": "0.6.12",
"description": "javascript interface for ftmq",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ftmq"
version = "0.6.11"
version = "0.6.12"
description = "followthemoney query dsl and io helpers"
authors = ["Simon Wörpel <[email protected]>"]
license = "MIT"
Expand All @@ -27,7 +27,7 @@ ftmq = "ftmq.cli:cli"
[tool.poetry.dependencies]
python = ">=3.11,<4"
banal = "^1.0.6"
followthemoney = "^3.6.3"
followthemoney = "^3.6.4"
orjson = "^3.10.3"
PyICU = "^2.13.1"
click = "^8.1.7"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
max-line-length = 88
select = C,E,F,W,B,B950
extend-ignore = E203, E501
extend-ignore = E203, E501, W503
29 changes: 29 additions & 0 deletions tests/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,35 @@ def test_sql():
""",
)

# simplified if no properties, reversed or search:
q = Query()
assert _compare_str(
q.sql.statements,
"""
SELECT test_table.id, test_table.entity_id, test_table.canonical_id,
test_table.prop, test_table.prop_type, test_table.schema, test_table.value,
test_table.original_value, test_table.dataset, test_table.lang,
test_table.target, test_table.external, test_table.first_seen,
test_table.last_seen FROM test_table ORDER BY test_table.canonical_id
""",
)
q = Query().where(dataset="foo", schema="Person")
assert _compare_str(
q.sql.statements,
"""
SELECT test_table.id, test_table.entity_id, test_table.canonical_id,
test_table.prop, test_table.prop_type, test_table.schema,
test_table.value, test_table.original_value, test_table.dataset,
test_table.lang, test_table.target, test_table.external,
test_table.first_seen, test_table.last_seen FROM test_table WHERE
test_table.dataset = :dataset_1 AND test_table.schema = :schema_1 ORDER
BY test_table.canonical_id
""",
)

# but we need complex query if we want a limit:
assert "canonical_id IN" in str(q[:10].sql.statements)


def test_sql_search_query():
q = Query().search("agency", ["name"])
Expand Down
6 changes: 6 additions & 0 deletions tests/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def _run_store_test(cls: Store, proxies, **kwargs):
break
assert tested

# iterate
entities = [e for e in store.iterate()]
assert len(entities) == 474 + 151
entities = [e for e in store.iterate(dataset="eu_authorities")]
assert len(entities) == 151

view = store.default_view()
ds = make_dataset("eu_authorities")
view = store.view(ds)
Expand Down