haxetink / tink_sql

SQL embedded into Haxe
MIT License
53 stars 16 forks source link

[sqlite]support ":memory:" database #103

Closed sonygod closed 4 years ago

sonygod commented 4 years ago

current sqlite version do not support ":memory:" database.

please consider to support !

test

benmerckx commented 4 years ago

The test suite runs fine on a :memory: database: https://github.com/haxetink/tink_sql/commit/5e1567d62000cb00d3a240d16c7df67b6472da3f Could you reduce the example or be more specific what fails?

sonygod commented 4 years ago
import tink.sql.Database;
import tink.sql.Types;

typedef Customer = {
    @:autoIncrement @:primary public var id(default, null):Id<Customer>;
    public var avatar(default, null):VarChar<50>;
}

class Db extends tink.sql.Database {
    @:table var fa_customer:Customer;

    public var user(get, never):tink.sql.Table<{fa_customer:Customer}>;

    inline function get_user()
        return fa_customer;
}

class Main {
    static var db:Db;

    static function main() {
        var driver2 = new tink.sql.drivers.Sqlite(function(db) {
            return ":memory:";
        });
        db = new Db('fa_klw', driver2);

        db.user.create();
        trace('create table'); // work.
        testInsert().next(function(id) {
            trace("id=" + id);//no trace?
            return id;
        });

        trace("finish");
    }

    static function testInsert() {
        return db.user.insertOne({
            id: cast null,
            avatar: "TEST.PNG",
        });
    }
}
kevinresol commented 4 years ago

Test running fine. Closing.