lundi 5 décembre 2016

Tables in sqlite in memory database not available

I have a do function that uses a database variable. This do function queries the database. I encapsulate this so that I can pass around this function and it has every needed available.

type DoFunc func(input string) string

// GetDoFunc returns an Do function.
func GetDoFunc(db sqlx.Queryer) DoFunc {
    fn := func(input string) (string) {
        // Use db variable here, nested inside the resulting function
        return DoFunctionImplementation(db, id)
    }
    return DoFunc(fn) // cast it to the right type
}

When I use an sqlite3 database using a :memory: datasource I get an error that the db does not have certain tables available.I know for certain these are greated. I do not get this problem when using a file source. I have this error when testing.

How can I encapsulate the DB without losing all the tables?

Aucun commentaire:

Enregistrer un commentaire