Brief for Cedric: inline parameters when the connection is attached over Quack (FLT-281)¶
You are Cedric Jones-Gaffney (Codex), the implementer. Clahadore orchestrates.
Problem (production, 2026-10-31)¶
Every parameterized EF query against an attached Quack catalog fails with:
Invalid Input Error: Values were not provided for the following parameters: p1, p...
This is the known Quack limitation duckdb/duckdb-quack#323: Quack's PREPARE request carries only the SQL text. Other clients work around it by inlining bound values as SQL literals on the client side, in Quack mode only:
Statements without parameters already work over Quack.
Task¶
Work in this worktree (C:\Users\fives\source\repos\EFCore.DuckDB.wt\quack-tls, branch quack-tls). Edit files only, because .git is read-only for you; Clahadore will commit.
- When a connection is configured with
UseQuack(...), add aDbCommandInterceptorthat rewrites each command before execution (sync and async: Reader, NonQuery, Scalar): - Replace every parameter placeholder in
CommandTextwith the SQL literal for its value.- Find out exactly which placeholder syntax this provider emits. Check
DuckDBSqlGenerationHelperand the parameter naming, e.g.$p0vs$1vs?. - Generate the literal with the provider's own
RelationalTypeMapping.GenerateSqlLiteralfor the parameter's type mapping. Those literals are already round-trip tested. Fall back to the mapping source by CLR type, and NULL for DBNull/null.
- Find out exactly which placeholder syntax this provider emits. Check
- Then clear
Parameters. - Safety is the whole point. The rewrite must never touch characters inside string literals, quoted identifiers, or comments that only look like placeholders.
- Write a small, correct SQL lexer: single-quoted strings with doubled-quote escapes, double-quoted identifiers,
--and/* */comments, and dollar-quoted strings if DuckDB supports them. - Replace only real placeholders. Match each placeholder to its parameter exactly:
$p1must not match the start of$p10. If a placeholder has no parameter, or a parameter has no placeholder, throw a clear error. Never send a partly bound statement. - Literal escaping must make injection impossible.
- Add tests with hostile values:
'; DROP TABLE x; --, embedded quotes, backslashes,$p1inside a string value, NUL, unicode, very long strings, byte[] and Guid, DateTime and DateTimeOffset at the floor-to-microsecond boundary, decimal precision, and enums. - Logging. Inlined values can include personal data. Log the original parameterized SQL, never the inlined text. Keep the existing token/fingerprint redaction.
- Prove it end to end. Run a local DuckDB 2.0.0 Quack server with the CLI at
C:\Tools\duckdb\2.0.0\duckdb.exe, generating the token at runtime from an env var and never putting a literal in an argument. Then do a small EF CRUD run throughUseQuackagainst it, and record the receipts inQUACK-PARAMS-RESULT.md. - The repo's tests use the 1.5.6 native from DuckDB.NET.Data.Full, which cannot talk to a 2.0 server. For this e2e, point DuckDB.NET at a 2.0 native if one is available. Otherwise record that it was not runnable and why, and rely on unit tests of the rewritten SQL.
- A Linux libduckdb 2.0 exists in
gs://verse4verse-prod-quack-artifacts/v2.0.0/, but you have no GCP access, so don't try. - Run
dotnet build -c Release -m:1anddotnet test -c Release -m:1serially; the PC is under memory pressure. Bump the version to 0.1.2. Rundotnet pack -c Release. - Write
QUACK-PARAMS-RESULT.md. Include the files changed, test totals before and after, the e2e receipts or the reason there are none, and the nupkg path. End with a list of anything you could not do.