-
-
Notifications
You must be signed in to change notification settings - Fork 579
Fix slicing of resource attributes during generation #1542
Fix slicing of resource attributes during generation #1542
Conversation
Seems like the integration tests failed on travis. I did not run those locally. :( |
Error message is I'm only on mobile until this evening, will have a look at why this test might be failing. Maybe you can have a look at it as well? https://github.com/gobuffalo/buffalo/blob/development/.travis.yml#L37-L38 |
There needs to be an |
I think I fixed it. // Check if any attributes are given
if len(args) > 1 {
ats, err := attrs.ParseArgs(args[1:]...)
if err != nil {
return errors.WithStack(err)
}
resourceOptions.Attrs = ats
} But I'm getting confused with all the auto generated files, that are being created during |
And we have another problem. With my fix, the generated templates have the correct field, but the model & migrations are missing the first one: buffalo generate resource restaurant name address web Output: type Restaurant struct {
ID uuid.UUID `json:"id" db:"id"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
Address string `json:"address" db:"address"`
Web string `json:"web" db:"web"`
} Template <%= f.InputTag("Name") %>
<%= f.InputTag("Address") %>
<%= f.InputTag("Web") %>
<button class="btn btn-success" role="submit">Save</button> It seems like the error (index mismatch) is happening later in the chain |
https://github.com/gobuffalo/buffalo/blob/development/genny/resource/models.go#L12 that's where the call to buffalo-pop is being made to generate the resources. That's probably not sending the correct payload. |
I fixed it with the following changes: func modelCommand(model name.Ident, opts *Options) *exec.Cmd {
args := opts.Attrs.Slice()
args = append(args[:0], args[0:]...) // Used to be: append(args[:0], args[0+1:]...)
// ... I'm a little confused by the second line since it doesn't seem to change anything. When I run: func modelCommand(model name.Ident, opts *Options) *exec.Cmd {
args := opts.Attrs.Slice()
fmt.Println(args)
fmt.Println(reflect.TypeOf(args))
args = append(args[:0], args[0:]...)
fmt.Println(args)
fmt.Println(reflect.TypeOf(args)) The output is: [category price]
[]string
[category price]
[]string I can push my changes, but it would be nice to know how to handle the auto-generated files in that I talked about above. I don't want to commit unnecessary stuff. |
I've opened a PR with, what should be, the "correct" fixes. :) @tobiashienzsch can you review/test and let me know if that works for you? |
Looks good. No problems yet |
@tobiashienzsch do you want copy the changes from my PR to yours so you can get the, appropriate credit, for the work? You did a lot, I don't want to take that from you. I'm happy to kill my PR if you make the same changes in yours. |
@markbates No not at all, that was by mistake. Not yet used to the GitHub workflow, I workly manly on my own. Sorry for the confusion. |
@tobiashienzsch you haven't done anything wrong at all. :) I opened my branch to help you. I want you to get full credit for fixing the problem, that's why I suggested you copy the changes into your branch, so we can merge your PR, and not mine. I don't want to take anything away from all the hard work you put into this. |
Ok, that means, that I merge your branch into mine and then push again, right? |
…-resource-generation-fields
Travis failed with the same as on your commits, something with the sqlite test on windows. |
It’s happening on all the branches, I’m trying to figure it out, but travis isn’t helping. :( Also, it works just fine with the same version of go/mods on my windows laptop, so i don’t know what’s going on. :(
…-----------
Mark Bates
On Jan 23, 2019, 9:37 PM -0500, tobiashienzsch ***@***.***>, wrote:
Travis failed with the same as on your commits, something with the sqlite test on windows.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
For me, the test for buffalo/cmd/internal/integration completed after 372 seconds, I'm not sure what the travis timeout is, maybe it took even longer on the travis machine? |
See Issue #1540