qor / exchange

QOR exchange provides conversion (import/export) functionality for any Qor.Resource to CSV, Excel file
MIT License
17 stars 15 forks source link

Adding a meta name that doesn't exist in model, give no obvious error #2

Open sunfmin opened 8 years ago

sunfmin commented 8 years ago

The error has no error message:

14:24:34: daemon: productsadmin
runtime/debug.PrintStack()
    /Users/sunfmin/go/src/runtime/debug/stack.go:16 +0x22
github.com/theplant/aigle/vendor/github.com/qor/qor/utils.ExitWithMsg(0x4da820, 0xc4202005d0, 0xc420497d60, 0x2, 0x2)
    /Users/sunfmin/gopkg/src/github.com/theplant/aigle/vendor/github.com/qor/qor/utils/utils.go:175 +0x161
github.com/theplant/aigle/vendor/github.com/qor/qor/resource.(*Meta).Initialize(0xc4202d4e78, 0x0, 0x0)
    /Users/sunfmin/gopkg/src/github.com/theplant/aigle/vendor/github.com/qor/qor/resource/meta.go:210 +0x776
github.com/theplant/aigle/vendor/github.com/qor/exchange.(*Meta).updateMeta(0xc4202d4e70)
    /Users/sunfmin/gopkg/src/github.com/theplant/aigle/vendor/github.com/qor/exchange/meta.go:49 +0x135
github.com/theplant/aigle/vendor/github.com/qor/exchange.(*Resource).Meta(0xc420162f00, 0xc4202d4e70, 0xc4202d4dc0)
    /Users/sunfmin/gopkg/src/github.com/theplant/aigle/vendor/github.com/qor/exchange/exchange.go:56 +0x47
github.com/theplant/aigle/products/productsadmin/resources.init.1()
    /Users/sunfmin/gopkg/src/github.com/theplant/aigle/products/productsadmin/resources/exchange.go:14 +0x207
github.com/theplant/aigle/products/productsadmin/resources.init()
    /Users/sunfmin/gopkg/src/github.com/theplant/aigle/products/productsadmin/resources/worker.go:88 +0x60
main.init()
    /Users/sunfmin/gopkg/src/github.com/theplant/aigle/products/productsadmin/main.go:21 +0x3d
2016/10/05 14:24:34 Listening on :5000 with process id: 7765

example:

type Product struct {
    Code string `gorm:"primary_key"`
}

If you do, it gives this error:

func init() {
    ProductExchange = exchange.NewResource(&db.Product{}, exchange.Config{PrimaryField: "Code"})
    ProductExchange.Meta(&exchange.Meta{Name: "Price"})
}
sunfmin commented 8 years ago

the Price doesn't exists in models, should give better error message.