Skip to content

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.

  1. When a connection is configured with UseQuack(...), add a DbCommandInterceptor that rewrites each command before execution (sync and async: Reader, NonQuery, Scalar):
  2. Replace every parameter placeholder in CommandText with the SQL literal for its value.
    • Find out exactly which placeholder syntax this provider emits. Check DuckDBSqlGenerationHelper and the parameter naming, e.g. $p0 vs $1 vs ?.
    • Generate the literal with the provider's own RelationalTypeMapping.GenerateSqlLiteral for 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.
  3. Then clear Parameters.
  4. Safety is the whole point. The rewrite must never touch characters inside string literals, quoted identifiers, or comments that only look like placeholders.
  5. 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.
  6. Replace only real placeholders. Match each placeholder to its parameter exactly: $p1 must 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.
  7. Literal escaping must make injection impossible.
  8. Add tests with hostile values: '; DROP TABLE x; --, embedded quotes, backslashes, $p1 inside a string value, NUL, unicode, very long strings, byte[] and Guid, DateTime and DateTimeOffset at the floor-to-microsecond boundary, decimal precision, and enums.
  9. Logging. Inlined values can include personal data. Log the original parameterized SQL, never the inlined text. Keep the existing token/fingerprint redaction.
  10. 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 through UseQuack against it, and record the receipts in QUACK-PARAMS-RESULT.md.
  11. 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.
  12. 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.
  13. Run dotnet build -c Release -m:1 and dotnet test -c Release -m:1 serially; the PC is under memory pressure. Bump the version to 0.1.2. Run dotnet pack -c Release.
  14. 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.