Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

models starting with a b produce errors #261

Closed
tsauter opened this issue Feb 25, 2017 · 9 comments
Closed

models starting with a b produce errors #261

tsauter opened this issue Feb 25, 2017 · 9 comments

Comments

@tsauter
Copy link
Contributor

tsauter commented Feb 25, 2017

Hi,

the code for database model generation produce invalid code when the model starts with a b.

func (b Boxes) String() string { b, _ := json.Marshal(b) return string(b) }

This results in compiler errors.

@stanislas-m
Copy link
Member

Hello,

this is an issue in https://github.com/markbates/pop, but I can reproduce it.

@fooflare
Copy link
Contributor

Isn't this a scope problem? b Boxes is inside the scope of the function and you are defining again b (b, _ := ...)

@stanislas-m
Copy link
Member

@fooflare The template for model generation defines the variable as "b", and the param as "the first letter of the model". I think this is a real issue.

@fooflare
Copy link
Contributor

I see, now I checked the lines in the issue you opened in pop. The problem is that the name you choose for the variable never can be used as a model name. I love the comments in the 3 functions that are causing the issues :-)

@fooflare
Copy link
Contributor

Oooops!!! I forgot to say that just changing the name of the variable to anything with more than one character would be enough.

@markbates
Copy link
Member

Sounds like an easy PR for someone. :)

@fooflare
Copy link
Contributor

Right now I'm not in front of the computer, but later if nobody does it, I will :-)

@stanislas-m
Copy link
Member

stanislas-m commented Feb 28, 2017

Since it's only a matter of minutes, I'm doing it now. :)

@markbates
Copy link
Member

Closed via https://github.com/markbates/pop/pull/39

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

No branches or pull requests

4 participants