go-jet / jet

Type safe SQL builder with code generation and automatic query result data mapping
Apache License 2.0
2.52k stars 118 forks source link

[Doc] Generate models via test cases #242

Closed canuran closed 1 year ago

canuran commented 1 year ago

Generating models from the command line is sometimes not easy to use, when we need to create a table while executing the command:

func TestJetGen(t *testing.T) {
    // after create table in memory
    wd, _ := os.Getwd()
    err := sqlitegen.GenerateDSN("file::memory:?cache=shared", path.Join(wd, "jetgen"))
    assert.Nil(t, err)
}

Even some companies' databases cannot be connected through dsn, but use it's sdk to create sql.DB objects. At this time, we need to rewrite the GenerateDSN method.

canuran commented 1 year ago

I found it from wiki.