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

wrong numbering with already numbered fields #18

Open
mark-kubacki opened this issue Jul 20, 2015 · 4 comments
Open

wrong numbering with already numbered fields #18

mark-kubacki opened this issue Jul 20, 2015 · 4 comments

Comments

@mark-kubacki
Copy link

bambam translates this struct…:

type Member struct {
    id             int64
    Username       string    `capid:"0"`
    UpdatedAt      time.Time `capid:"3" json:"LastUpdated"`
    Name           *string   `capid:"1" json:"DisplayName,omitempty"`
    IsAdmin        bool      `capid:"2"`
    PasswordHash   *string   `capid:"4" json:",omitempty"`
    PasswordSalt   *string   `capid:"5" json:",omitempty"`
    PrimaryGroupId *int      `capid:"6" json:",omitempty"`
    UrlToAvatar    *string   `json:",omitempty"`
}

To the following, assigning capid=3 twice:

type Member struct {
    id             int64
    Username       string    `capid:"0"`
    UpdatedAt      time.Time `capid:"3" json:"LastUpdated"`
    Name           *string   `capid:"1" json:"DisplayName,omitempty"`
    IsAdmin        bool      `capid:"2"`
    PasswordHash   *string   `capid:"4" json:",omitempty"`
    PasswordSalt   *string   `capid:"5" json:",omitempty"`
    PrimaryGroupId *int      `capid:"6" json:",omitempty"`
    UrlToAvatar    *string   `json:",omitempty" capid:"3"`
}

I have expected that it continued numbering, and assigned capid=7 to the last field.


Annotating the field with capid=7 will result in this error and no usable file output:

$ bambam -o capn.model -p model member.go
panic: problem in capid tag '' on field 'UrlToAvatar' in struct 'Member': number '7' is beyond the count of fields we have, largest available is 6
# …
    UrlToAvatar    *string   `capid:"7" json:",omitempty"`
}

Although not required in this example, the order of fields in a struct is important: If every member of a struct is comparable, then the struct becomes comparable. In that case you don't want to reorder fields to suit bambam.

@glycerine
Copy link
Owner

@wmark Thanks for reporting this. It is clearly a bug. I won't have time to take a look at this until the weekend. I'd be happy to review a fix if you'd like to prepare one.

@mark-kubacki mark-kubacki changed the title wrong numbering on with already numbered fields wrong numbering with already numbered fields Jul 23, 2015
@glycerine
Copy link
Owner

@wmark: sadly, I won't have time any time soon to get to this...

@mark-kubacki
Copy link
Author

Anyway, thanks for having looked into this. Perhaps someone else finds this and wants to pick it up.

@jaten-saucelabs
Copy link

jaten-saucelabs commented Oct 14, 2016

Oh. This is due to the lack of time.Time type support. That is, bambam doesn't claim to have time.Time support currently.

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

3 participants