Skip to content

Add test code - #50

Merged
pyohei merged 17 commits into
mainfrom
fix/test
Aug 15, 2026
Merged

pyohei merged 17 commits into
mainfrom
fix/test

Conversation

@pyohei

@pyohei pyohei commented Mar 22, 2026

Copy link
Copy Markdown
Owner

No description provided.

pyohei added 17 commits March 23, 2026 08:07
INSTALLED_APPS/MIDDLEWARE don't include django.contrib.auth or
django.contrib.messages, so referencing their context processors would
raise once a test renders a template via RequestContext.
Django 5.2 needs Python 3.10+; without python_requires, installing on
an older interpreter fails with a confusing dependency-resolution
error instead of a clear version message.
Django 5.2.12 officially supports both per PyPI classifiers, and the
test suite passes locally under 3.13 and 3.14.
Adds example/, a small Django project (Book/Books, matching the
top-level README) that can actually be migrated and served, rather
than only exercised through the test runner. Verified via runserver +
browser that createviewtable produces a queryable, aggregated view.

Along the way this surfaced a real gotcha: a ViewTable subclass keeps
Django's implicit auto "id" field by default, but get_query() doesn't
select an id column, so any query touching the default fields (not
just .values_list()) raises OperationalError. The example works around
it by making category the primary key.
Existing tests only exercise get_query() built through the Django ORM
query builder. Real-world usage (per user report) tends to hand-write
SQL with several joins instead, so this adds a case that mirrors that:
get_query() returns a plain SQL string joining three tables (INNER +
LEFT JOIN) with a GROUP BY, and a ROW_NUMBER()-synthesized id column
to satisfy Django's implicit primary key expectation.

Verified on Python 3.10-3.14 / their bundled sqlite3 (window function
support).
Extends the example app with Author/Publisher models and
AuthorPublisherSummary, a view_table backed by a hand-written SQL
string (not the ORM query builder) joining three tables with INNER +
LEFT JOIN and GROUP BY -- mirroring how the library is actually used
in production, per user report. The LEFT JOIN case (a book with no
publisher on record) is deliberately included in the seed data and
renders as "(none)" on the page.

Verified via runserver + browser, and via a clean pip install -e .
environment.
Nothing in the repo references it (no README mention, no CI usage),
and the example app under example/ now covers manual verification.
@pyohei
pyohei merged commit 74d5bbf into main Aug 15, 2026
10 checks passed
@pyohei
pyohei deleted the fix/test branch August 15, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant