gobuffalo / buffalo-auth

Buffalo auth plugin helps adding username password authentication to your app
https://gobuffalo.io
MIT License
41 stars 28 forks source link

fixed the bug in the extra args handling #93

Closed sio4 closed 1 year ago

sio4 commented 1 year ago

What is being done in this PR?

Currently, the type of all extra columns is set as string which is the default and the null handling is not working. With this fix,

Now the generated files are something like

type User 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"`
    Email        string    `json:"email" db:"email"`
    PasswordHash string    `json:"password_hash" db:"password_hash"`

    Password             string `json:"-" db:"-"`
    PasswordConfirmation string `json:"-" db:"-"`

    //Extra fields
    Age int          `json:"age" db:"age"`
    Bio nulls.String `json:"bio" db:"bio"`
}
create_table("users"){
    t.Column("id", "uuid", {"primary": true})
    t.Column("email", "string", {})
    t.Column("password_hash", "string", {})
    t.Column("age", "integer", {})
    t.Column("bio", "text", {"null": true})
}

for the same command used in #21, buffalo g auth age:int bio:nulls.Text.

fixes #21

What are the main choices made to get to this solution?

Actually, there could be better options such as integration with fizz, and improving the function and the logic used for extra arguments handling, but I just simply fixed the bug with a smaller modification while keeping the current implementation as is today.

List the manual test cases you've covered before sending this PR:

Manual test with a simple todo app.