Repository navigation
feat(orm): build parameterized single-table SQL - #98
Merged
Merged
Conversation
Add the dialect layer, identifier quoting and SELECT/INSERT/UPDATE/DELETE/COUNT builders on top of the model metadata. Every value is bound through uvcpp_db_params, PostgreSQL uses $1..$n, SQLite/MySQL use ?, and UPDATE/DELETE require a WHERE clause. Add golden-SQL, parameter-order and injection tests for all three dialects.
Owner
Author
|
Local review before merge: ORM SQL tests 295/295, ORM model 192/192, DB SQLite passes, C++11 pedantic build. No SQL is executed in this layer. Shared-runner CI remains queued. |
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.
Part of #88. Stacked on #96 (
feat/orm-model); retarget tomasterafter #96 merges. This PR does not close #90 yet — it is the SQL construction step; result mapping/CRUD is #91.What changed
Adds the SQL-construction layer above the model metadata:
src/orm/uvcpp_orm_dialect.h— explicit SQLite / MySQL / PostgreSQL dialect;?vs$1..$n; identifier quoting ("vs backtick) with quote doubling; invalid dialect is rejected rather than silently producing unquoted SQL.src/orm/uvcpp_orm_query.h— SELECT / INSERT / UPDATE / DELETE / COUNT builders:eq/ne/lt/le/gt/ge/like/in/is_null/is_not_null), AND groups and OR groups with explicit parentheses;raw(sql, params)escape hatch with a documented scanner limitation;uvcpp_db_params; no value literals are emitted.src/orm/uvcpp_orm_error.h/uvcpp_orm_status.cpp— construction/validation status codes.tests/functional/orm_sql_func.cpp— 295 checks: byte-exact golden SQL for three dialects, parameter order/count, identifier escaping, injection corpus, error paths andraw().No DB client, C ABI, connection ownership or existing
dbbehavior is changed. No SQL is executed in this layer.Verification
C++11 compile:
g++ -std=c++11 -pedantic-errorsexits 0. WithUVCPP_BUILD_ORM=OFF,test_orm_sql_funcis absent andtest_db_sqlite_funcstill passes.Golden examples covered include SQLite/MySQL
?, PostgreSQL$1..$n, MySQL backtick vs SQLite/PG double-quote escaping, UPDATE SET order + WHERE parameter order, DELETE WHERE, COUNT(*), empty IN, invalid order direction, negative LIMIT/OFFSET, missing WHERE, unknown columns and parameter-count mismatches.Unverified / known limits
raw()is a lexical scanner, not a SQL parser: PostgreSQL dollar-quoted strings and MySQL backslash escapes are caller responsibility, documented in the header..clang-formatin the repository; files follow the surrounding 2-space UTF-8 style.