Repository navigation
SQL backend: joins, full predicates, OFFSET/COUNT, pypika-free renderer - #13
Merged
Merged
Conversation
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.
Query chains already describe reads (filter/project/order/take); this makes the SQL backend execute them instead of just spelling single-table queries.
What
Joins + predicate language (
sql_builder.py)TABLE/ALIASoverrides on query classes (MembershipQuery → memberships)visit_edgeemits INNER JOIN via a newJoinOn(left, right)edge contextast.Expr): AND/OR,is None/is not None,in(empty set matches nothing, not invalid SQL), call-formlike(col, pat)/match(col, q)(FTS5 via newMatchCriterion),desc()/lower(), multi-key and bare-column order keysskip(n)op (OFFSET),visit_count, qualifiedproject()Runner (
query.py)MembershipQuery([])),to_sql_string(),to_rows(conn)(DBAPI → list of dicts)Renderer (
sql_render.py, new — drops pypika)?placeholder with params (stable plans, user input never touches SQL text)sqlextra (pypika) from pyprojectAlso: lazy polars import (hard import broke SQL-only users).
Verified
db.execSQLAlchemy reads on a 60-user/200-message database: sidebar (JOIN+AND+LOWER order), message windows (DESC keysets, OR anchor predicates), autocomplete (LIKE), counts, IN/empty-IN/IS NULL, FTS MATCH (parameterized) — 12/12 checksdb.exec)Example output: