schotime / NPoco

Simple microORM that maps the results of a query onto a POCO object. Project based on Schotime's branch of PetaPoco
Apache License 2.0
847 stars 301 forks source link

SqliteConnection misdetected as SqlServerConnection #687

Closed Hakon closed 1 year ago

Hakon commented 1 year ago

Hi,

I've been trying to track down an issue where my SqliteConnection is misdetected as an SqlServerConnection:

    [Fact]
    public void npoco_bug()
    {
        var c = new SqliteConnection("Data Source=test.db");
        var db = new NPoco.Database(c);
        Assert.Equal("SqlServerDatabaseType", db.DatabaseType.GetType().Name);
    }

I expected the DatabaseType to be SQLiteDatabaseType. The reason for the misdetection is due to the uppercase SQLite in the Resolve method on DatabaseType. Is there another SqliteConnection type that I should be aware of that has the SQL capitalised?

I can make a patch if this is indeed a bug.

Regards, Håkon

schotime commented 1 year ago

Sounds like a bug, can probably just add a , StringComparison.OrdinalIgnoreCase as the second parameter to StartsWith on that line you referenced.