Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interesting Generation Error #5

Closed
chrisfentiman opened this issue Sep 18, 2017 · 3 comments
Closed

Interesting Generation Error #5

chrisfentiman opened this issue Sep 18, 2017 · 3 comments

Comments

@chrisfentiman
Copy link

First off, awesome job on this package, I was really impressed with the api it generated so much so we started migrating our GORM queries across to use this package instead.

So the issue is I have an Enum that is imported from another package. This seems to work fine on other code generations we have. However, when I generated code using go-queryset I got an unexpected result.

The struct // gen:qs is above looks like this:

type Example struct {

	PriceID int64

	Currency forex.Currency

        ....
}

The Generated code for currency looks like this:

// CurrencyEq is an autogenerated method
// nolint: dupl
func (qs ExampleQuerySet) CurrencyEq(currency v1.Currency) ExampleQuerySet {
	return qs.w(qs.db.Where("currency = ?", currency))
}

// CurrencyGt is an autogenerated method
// nolint: dupl
func (qs ExampleQuerySet) CurrencyGt(currency v1.Currency) ExampleQuerySet {
	return qs.w(qs.db.Where("currency > ?", currency))
}

....

The error is that the generated code has placed v1 as the package selector and not the actual package name forex.

This is non-blocking for me as It's very easy to fix up manually. However, this would suggest that the code generation is picking up v1 from the file path? The import is like so: import "go.company.com/internal-files/companyapi/forex/v1".

Happy to help look into this problem but I thought I'd raise it first just in case something like this has occurred else where.

@jirfag
Copy link
Owner

jirfag commented Sep 19, 2017

Hello!
Thank you for report, I will look at it in 24h and try to fix it ASAP

@jirfag
Copy link
Owner

jirfag commented Sep 19, 2017

Fixed bug in master, check it please

@chrisfentiman
Copy link
Author

Works perfectly. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants