Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dialect_sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,16 @@ func (m *sqlite) FizzTranslator() fizz.Translator {
}

func (m *sqlite) DumpSchema(w io.Writer) error {
cmd := exec.Command("sqlite3", m.Details().Database, ".schema")
cmd := exec.Command("sqlite3", m.Details().Database, ".schema --nosys")
return genericDumpSchema(m.Details(), cmd, w)
}

func (m *sqlite) LoadSchema(r io.Reader) error {
cmd := exec.Command("sqlite3", m.ConnectionDetails.Database)
cmd.Stderr = os.Stderr
in, err := cmd.StdinPipe()
if err != nil {
return err
return fmt.Errorf("could not open stdin to SQLite database %s: %w", m.ConnectionDetails.Database, err)
}
go func() {
defer in.Close()
Expand All @@ -246,12 +247,12 @@ func (m *sqlite) LoadSchema(r io.Reader) error {
log(logging.SQL, strings.Join(cmd.Args, " "))
err = cmd.Start()
if err != nil {
return err
return fmt.Errorf("could not load schema to SQLite database %s: %w", m.ConnectionDetails.Database, err)
}

err = cmd.Wait()
if err != nil {
return err
return fmt.Errorf("command failure loading schema to SQLite database %s: %w", m.ConnectionDetails.Database, err)
}

log(logging.Info, "loaded schema for %s", m.Details().Database)
Expand Down
2 changes: 2 additions & 0 deletions executors.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func (c *Connection) Create(model interface{}, excludeColumns ...string) error {
}
stm := after[index].AfterProcess()
if c.TX != nil && !stm.Empty() {
log(logging.SQL, stm.Statement, stm.Args)
_, err := c.TX.Exec(c.Dialect.TranslateSQL(stm.Statement), stm.Args...)
if err != nil {
return err
Expand All @@ -297,6 +298,7 @@ func (c *Connection) Create(model interface{}, excludeColumns ...string) error {
for index := range stms {
statements := stms[index].Statements()
for _, stm := range statements {
log(logging.SQL, stm.Statement, stm.Args)
if c.TX != nil {
_, err := c.TX.Exec(c.Dialect.TranslateSQL(stm.Statement), stm.Args...)
if err != nil {
Expand Down