Skip to content

Added :text format test case and updated test project to have all supported frameworks#30

Open
terryaney wants to merge 2 commits intoDrizin:mainfrom
terryaney:feature/text-format-test
Open

Added :text format test case and updated test project to have all supported frameworks#30
terryaney wants to merge 2 commits intoDrizin:mainfrom
terryaney:feature/text-format-test

Conversation

@terryaney
Copy link
Contributor

No description provided.

The problem only presents itself when using XElement:text format in MS SQL Server because there is a Xml type.  In unit tests or other databases (i.e. SQLLite) that don't have a Xml type, the XElement is converted to string automatically without issue.

Root Transformation Problem: XElement implements IEnumerable<XNode>, so when checking argumentValue is IEnumerable<object> at ~InterpolatedSqlParser.cs:250, XElements were being treated as collections instead of single values that need string conversion.

In addition to that fix, another problem was NET6+ handler goes directly to AppendArgument, bypassing ProcessArgument where TransformArgument is called.

The fix: Make AppendArgument call TransformArgument so both paths (FormattableString and InterpolatedStringHandler) get the full transformation logic, which means:

1. NET6+ InterpolatedStringHandler → AppendArgument → TransformArgument
2. Legacy FormattableString → Parser.ParseInsert → ProcessArgument → TransformArgument
@terryaney
Copy link
Contributor Author

See my new commit comment...it explains what I found/did/why.

Note: I had copilot help me, but reviewing the fix, it seems valid but you'd probably know better than me/AI.

I tried to run tests (I had to download/install AdventureWorks db) and I had some errors, but digging...

  1. System.Data.SqlClient not supported on platform - Most failures are because the tests use the old System.Data.SqlClient package which doesn't work properly on newer .NET. Should the test project be updated??
  2. Missing stored procedure - Tests looking for dbo.sp_TestOutput which doesn't exist in my install of AdventureWorks2019??
  3. Duplicate key error - TestFullInsert failing because it's trying to insert a product that already exists (possibly from a previous test run??).

@terryaney
Copy link
Contributor Author

InterpolatedSql.ToStringRepro.zip
Here is/was my repro app. When I was using SQLLite, everything worked without any changes, but when using SQL Server (via LocalDB) then the problem was reproducible.

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