Description
File a bug
We moved to Microsoft.Data.Sqlite 6, as it has better support for dropping columns in Sqlite by my understanding
In our move, we encountered the old GetSchema issue, which seems to be addressed in v6...kind of.
NHibernate used to get around the issue by catching the NotSupportedException. Now it doesn't throw, but instead goes through:
SqliteDialect -> SqliteDataBaseMetaData -> AbstractDataBaseSchema -> GetReservedWords() -> Connection.GetSchema(string) with this implementation:
public virtual ISet<string> GetReservedWords()
{
var result = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
DataTable dtReservedWords = Connection.GetSchema(DbMetaDataCollectionNames.ReservedWords);
foreach (DataRow row in dtReservedWords.Rows)
{
result.Add(row["ReservedWord"].ToString());
}
if (IncludeDataTypesInReservedWords)
{
DataTable dtTypes = Connection.GetSchema(DbMetaDataCollectionNames.DataTypes);
foreach (DataRow row in dtTypes.Rows)
{
result.Add(row["TypeName"].ToString());
}
}
return result;
}
which then goes to SqliteConnection.GetSchema(string collectionName, Array.Empty())
public override DataTable GetSchema(string collectionName, string?[] restrictionValues)
{
if (restrictionValues is not null && restrictionValues.Length != 0)
{
throw new ArgumentException(Resources.TooManyRestrictions(collectionName));
}
if (string.Equals(collectionName, DbMetaDataCollectionNames.MetaDataCollections, StringComparison.OrdinalIgnoreCase))
{
return new DataTable(DbMetaDataCollectionNames.MetaDataCollections)
{
Columns =
{
{ DbMetaDataColumnNames.CollectionName },
{ DbMetaDataColumnNames.NumberOfRestrictions, typeof(int) },
{ DbMetaDataColumnNames.NumberOfIdentifierParts, typeof(int) }
},
Rows =
{
new object[] { DbMetaDataCollectionNames.MetaDataCollections, 0, 0 },
new object[] { DbMetaDataCollectionNames.ReservedWords, 0, 0 }
}
};
}
else if (string.Equals(collectionName, DbMetaDataCollectionNames.ReservedWords, StringComparison.OrdinalIgnoreCase))
{
var dataTable = new DataTable(DbMetaDataCollectionNames.ReservedWords)
{
Columns =
{
{ DbMetaDataColumnNames.ReservedWord }
}
};
int rc;
string keyword;
var count = sqlite3_keyword_count();
for (var i = 0; i < count; i++)
{
rc = sqlite3_keyword_name(i, out keyword);
SqliteException.ThrowExceptionForRC(rc, null);
dataTable.Rows.Add(new object[] { keyword });
}
return dataTable;
}
throw new ArgumentException(Resources.UnknownCollection(collectionName));
}
DataTypes isn't handled there, so if IncludeDataTypesInReservedWords
is true, which it always is for SqliteDataBaseMetaData, then it will throw the ArgumentException.
I don't how important DataTypes is in this context, but there's the research I've done. Hope I helped.