TableInfo static type cache needs to be Provider specific
Closed this issue · 1 comments
In my unit tests I use both Sqlite and Mysql connections with SqlFu. Unfortunately this can break insert statements because the TableInfo class caches the insert SQL across all providers even thought they have different formatting requirements.
For example:
SQLite - Insert into "IdempotentRecord" ("TargetKey","InvocationId") values(?0,?1);
Mysql - Insert into IdempotentRecord
(TargetKey
,InvocationId
) values(?0,?1);
So If I use SqlFu to insert an IdempotentRecord
using an Sqlite connection and then try the same thing using a MySql connection (within the same set of tests on the same assembly) then the Mysql insert fails with an invalid format exception.
I have a workaround to clear the cache that allows my tests to succeed and me to move on:
var type = typeof (SqlFuConnection).Assembly.GetType("SqlFu.Internals.TableInfo");
var field = type.GetField("_cache", BindingFlags.Static | BindingFlags.NonPublic);
var dictionary = (IDictionary) field?.GetValue(null);
dictionary?.Clear();
Can you please make the TableInfo cache be by Provider
+ Type
to resolve this problem?
released a new version which should take care of that