DapperLib / Dapper

Dapper - a simple object mapper for .Net
https://www.learndapper.com/
Other
17.59k stars 3.68k forks source link

Is Dapper.Rainbow not supporting SQLite? #1080

Open cnxy opened 6 years ago

cnxy commented 6 years ago

When I use Dapper.Rainbow for SQLite, the following message appears: System.Data.SQLite.SQLiteException: "SQL logic error No such table: INFORMATION_SCHEMA.TABLES" Is Dapper.Rainbow not supporting SQLite?

The code show as below:

 class Program
    {
        static void Main(string[] args)
        {
            string fileName = "MyDatabase.db";
            if (!File.Exists(fileName)) SQLiteConnection.CreateFile(fileName);
            SQLiteConnection connection = new SQLiteConnection($"Data Source = {fileName}");
            MyDatabase db = MyDatabase.Init(connection, 2000);
            db.Execute("CREATE TABLE IF NOT EXISTS Cat(Id integer PRIMARY KEY AUTOINCREMENT, Name text NOT NULL)");
            db.Cats.Insert(new Cat { Name = "Tom" });
        }
    }
    class MyDatabase:Database<MyDatabase>
    {
        public Table<Cat> Cats { set; get; }
    }
    class Cat
    {
        public int? Id { set; get; }
        public string Name { set; get; }
    }
mdockal commented 6 years ago

I have the same issue, so this is a bug. SQLite doesn't have a table called INFORMATION_SCHEMA.TABLES updated the code to detect if it is a SQLite connection. Created Pull Request #1095

gerdus commented 1 week ago

Ran into this today, not nice. Rainbow seems to do same job as Dapper.Contrib? Which is also unmaintained. Please just add a note to the readme stating it only works with SQL Server.