go-reform / reform

A better ORM for Go, based on non-empty interfaces and code generation.
https://gopkg.in/reform.v1
MIT License
1.44k stars 73 forks source link

Skip sqlite3 tables with incorrect table_info #180

Closed eschizoid closed 4 years ago

eschizoid commented 6 years ago

I have a third party database that I cannot change it. Is there a way to silently fail and still generate the correct entities?

reform-db: 2018/11/10 04:33:51.656895 cmd_init_sqlite3.go:85: no such module: spellfix1
panic: no such module: spellfix1

goroutine 1 [running]:
gopkg.in/reform.v1/internal.(*Logger).Fatalf(0xc0000938f0, 0x45377d0, 0x2, 0xc000348a60, 0x1, 0x1)
    /Users/mgonzalez/go/src/gopkg.in/reform.v1/internal/logger.go:51 +0x107
main.initModelsSQLite3(0xc00009c8a0, 0xc0000dbbd0, 0x400b9bd, 0x44dd240)
    /Users/mgonzalez/go/src/gopkg.in/reform.v1/reform-db/cmd_init_sqlite3.go:85 +0x469
main.cmdInit(0xc00009c8a0, 0xc00001e004, 0x1f)
    /Users/mgonzalez/go/src/gopkg.in/reform.v1/reform-db/cmd_init.go:184 +0xb2f
main.main()
    /Users/mgonzalez/go/src/gopkg.in/reform.v1/reform-db/main.go:128 +0x3a4

Something like the following:

https://stackoverflow.com/questions/38425835/reflecting-sqlite-database-with-spellfix1-tables

Edit: Even better, something like --skip-tables I think would be less invasive?

AlekSi commented 6 years ago

Is it the same as #174?

eschizoid commented 6 years ago

@AlekSi Yes, you want me to close this one?

AlekSi commented 6 years ago

Closing as duplicate of #174.

AlekSi commented 6 years ago

Ok, that's a somewhat different issue. Reopening. The proper fix is to log an error and continue to the next loop iteration there. PRs are welcome.

eschizoid commented 6 years ago

@AlekSi I think that this behavior (skipping failures) should be configurable. How you feel about adding an extra flag to comand-db. Either way I can take the work, just checking what are your thoughts about it.

vmaggioli commented 5 years ago

Is this flag still needed? I can give this a shot