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

Support default value. #209

Closed
wants to merge 2 commits into from
Closed

Support default value. #209

wants to merge 2 commits into from

Conversation

shellmanme
Copy link

Support default value. (i.e. "uuid()", "uuid_short()", etc).

Support default value. (i.e. "uuid()", "uuid_short()", etc).
@shellmanme shellmanme changed the title Update gorp.go Support default value. Nov 7, 2014
@GeertJohan
Copy link
Member

Please add test cases and re-open this PR on master branch (we've deprecated the develop branch)

@GeertJohan
Copy link
Member

@zallwu If you could add a testcase and docs, as well as rebase to master, then we could merge this at v2-phase1 (see #270). Otherwise we'll have to postphone it to v2.1, at which point the codebase will have changed a lot.

@GeertJohan
Copy link
Member

Looked at the code again. I think it would be better to add default as a part of the db tag:
db:"name, default:uuid()"

@GeertJohan
Copy link
Member

I'll merge and add open an issue so we can work it out in phase3.

@GeertJohan
Copy link
Member

Merged at 96583e8

@GeertJohan GeertJohan closed this Jul 2, 2015
@GeertJohan
Copy link
Member

Actually added the default option to the db tag just now..

@wzzhu
Copy link

wzzhu commented Nov 27, 2015

This is not completed. Should add the patch below:

--- a/table.go
+++ b/table.go
@@ -211,6 +211,9 @@ func (t *TableMap) SqlForCreate(ifNotExists bool) string {
if col.Unique {
s.WriteString(" unique")
}

  •                   if col.DefaultValue != "" {
    
  •                           s.WriteString(fmt.Sprintf(" default %s", col.DefaultValue))
    
  •                   }
                    if col.isAutoIncr {
                            s.WriteString(fmt.Sprintf(" %s", dialect.AutoIncrStr()))
                    }
    

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

Successfully merging this pull request may close these issues.

3 participants