Skip to content

feat: complete ORM query builder and model-driven workflows#311

Merged
KKould merged 38 commits intomainfrom
feat/orm_builder
Mar 21, 2026
Merged

feat: complete ORM query builder and model-driven workflows#311
KKould merged 38 commits intomainfrom
feat/orm_builder

Conversation

@KKould
Copy link
Member

@KKould KKould commented Mar 21, 2026

What problem does this PR solve?

KiteSQL already had the first piece of ORM support, but it still could not cover most of KiteSQL's query and maintenance capabilities through a consistent high-level API.

This PR completes that layer so model-driven workflows can stay inside the ORM for projections, joins, subqueries, set queries, mutations, introspection, and related documentation/tests, instead of falling back to raw SQL or exposed AST details.

Issue link:

What is changed and how it works?

ORM query builder

  • Rebuild ORM DQL/DML/DDL construction on top of sqlparser AST while keeping AST details hidden from end users
  • Expand expression support with function calls, arithmetic, aggregates, CASE, aliased values, DISTINCT, and richer subquery predicates
  • Add group_by, having, tuple/value projections, and DTO projections via #[derive(Projection)]
  • Add source aliasing, typed joins, USING, cross joins, and join-aware struct projections
  • Unify composable query sources under QueryOperand and support UNION / EXCEPT with result-level ordering, limits, count, exists, get, and explain

ORM mutations and maintenance

  • Unify query-driven mutations under from::<M>()...update()/delete()
  • Add INSERT ... SELECT support and ORM-side insert/overwrite builders at the end of query chains
  • Add convenience helpers such as insert_many, truncate, create_view, create_or_replace_view, drop_view, show_tables, show_views, describe, and explain
  • Keep the ORM surface focused on high-level model/query workflows rather than explicit AST export APIs

Fixes, docs, and tests

  • Fix correlated IN subqueries, set-query binding/top-level ordering, and EXCEPT DISTINCT / EXCEPT ALL semantics
  • Expand ORM macro tests and add SLT coverage for subqueries, unions/except, and insert-from-query cases
  • Rework ORM rustdoc and README so the final API surface is documented around the current builder design

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

This PR is large because it carries the whole ORM completion pass on top of the initial model-driven ORM groundwork. The main thread is: finish the ORM around the existing KiteSQL capability surface, keep AST details internal, and add enough tests/docs to make the new builder flow stable and understandable.

KKould added 30 commits March 18, 2026 00:06
@KKould KKould self-assigned this Mar 21, 2026
@KKould KKould changed the title docs: streamline ORM README and trim partial examples feat: complete ORM query builder and model-driven workflows Mar 21, 2026
@KKould KKould merged commit a5fbb88 into main Mar 21, 2026
14 checks passed
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