Repository navigation
Query endpoint: evaluate guest queries on RestrictedDb raw data, and fix select value types on SQL backends - #1113
Merged
Conversation
…atches in one pass SQL path: rows go through GOQL's `select_normalizer`, so each selected value has the type Gramps' schema gives it, as on the proxied path. Booleans were 0/1 (and "true"/"false" text for JSON booleans on PostgreSQL), and JSON numbers were strings on PostgreSQL. This replaces `_needs_json_decoding` / `_normalize_json_value`, which only decoded objects and lists. Proxied path: `RestrictedDb` is read as raw data (`RawDataReader`), and `X-Total-Count` comes from `run_query_with_total`'s single pass instead of a second, unlimited `run_query` whenever the matches span more than one page. Needs gramps-object-query-language 0.5.7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A guest can't match, select or count a private place or event through a person. Reading related records past RestrictedDb makes the test fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dsblank
marked this pull request as ready for review
October 26, 2026 18:51
Member
|
Looks good! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This needs gramps-object-query-language 0.5.7, now on PyPI (release notes).
Summary
Guests: GOQL reads
RestrictedDbas raw data, and counts in the same pass (proxied path)These are the suggestions from dsblank/gramps-object-query-language#7:
RestrictedDbis read withRawDataReader, so no Gramps object is built per record. Gramps proxies (ProxyDbBase) keep the default object reader, since they build the object anyway.X-Total-Countcomes fromrun_query_with_total, which counts matches during the same pass that sorts them. Before, a counted request whose matches spanned more than one page read and cleaned every record a second time.On a 100k-person PostgreSQL tree, #7 measured guest queries 1.3–13× faster with
RawDataReader, before counting the second pass removed here.Bug fix: selected values have their schema types (SQL path)
On the SQL path,
/query/returned some selected values in the database's own form rather than their Gramps type:private,birth.private)00falseprimary_name.private)0"true"truebirth.date.sortval)2389036"2389036"2389036birth.date)primary_name.first_name)"123""123""123"The proxied path (guests) already returned these as
true/falseand numbers. Owners and guests now get the same values."false"as a string counts as true in JS and Python, so a client testingif (item.private)on PostgreSQL got the wrong answer._post_sqlnow runs each row through GOQL'sselect_normalizer. That replaces_needs_json_decoding/_normalize_json_value, which only decoded objects and lists. Their docstring said PostgreSQL values "arrive parsed", but scalars don't.Client-visible change: on SQL backends
privateis nowtrue/falseinstead of1/0, and on PostgreSQL JSON numbers and booleans are no longer strings. gramps-connect's list views already convertplace_typewithNumber()and select no boolean columns, so they're unaffected.Changes
resources/object_query.py:select_normalizerin_post_sql.RawDataReaderandrun_query_with_totalin_post_proxied. The two decoding helpers are removed.pyproject.toml:gramps-object-query-language>=0.5.7,<0.6.test_select_values_have_schema_types: checks value types for owner (SQL) and guest (proxied), and that a public person reads the same either way.test_guest_cannot_see_private_related_records: a guest can't match, select or count a private place or event through a person (birth.place.title,birth.description,any(...),len(...),count(...)), while the owner can. It fails if related records are read pastRestrictedDb.test_restricted_db_is_read_as_raw_data: a guest's query getsRawDataReader, a Gramps proxy the default reader.Test plan
test_object_query_parsing.py,test_access.py,test_privacy_canary.py, and intest_endpoints/:test_people_query.py,test_object_query.py,test_object_query_where_tree.py,test_filters.py: 276 passed against gramps-object-query-language 0.5.7privatecame back as0)RestrictedDb, and the reader test fails when guests get no readerisort and mypy report errors on unchanged lines that are already on
master.🤖 Generated with Claude Code