Skip to content

Commit

Permalink
Do not force convert Postgres's table name and field name to lower ca…
Browse files Browse the repository at this point in the history
…se. Fixes #119, #192.

To use lower case table name, do something like this: dbmap.AddTableWithName(Post{}, "posts")
To use lower case field name, specify the field name in type definition: type Post struct { Title   string `db:"title"` }
  • Loading branch information
vinceyuan committed Dec 24, 2015
1 parent 0c9bc09 commit 418d928
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dialect_postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (d PostgresDialect) InsertAutoIncrToTarget(exec SqlExecutor, insertSql stri
}

func (d PostgresDialect) QuoteField(f string) string {
return `"` + strings.ToLower(f) + `"`
return `"` + f + `"`
}

func (d PostgresDialect) QuotedTableForQuery(schema string, table string) string {
Expand Down

2 comments on commit 418d928

@mauleyzaola
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vinceyuan @coopernurse Hi guys, I have been using this wonderful orm since last year in many projects.
Since all my servers were already installed I just noticed today when deploying a new one, that my unit tests that consume gorp are breaking, due to this commit.

I don't know how come you figured it out to make such a big change or what are the reasons behind this, but in my opinion, it makes no sense. I believe most of the people that use Postgresql won't use uppercase in the tables.

I am going to temporary fork this project and of course, rollback this commit.

EDIT: I forgot to mention something else: in one project I use 1747 fields. Just imagine the work to label all of them to lowercase. Again, imho is stupid.

Please let me know what are your thoughts about it. Thanks.

@mauleyzaola
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see now where this came from: #119 so I can see there has been a discussion on this subject. Well, do you think this behavior can be somehow configurable from the SqlExecutor interface? I wouldn't mind to leave it like it is, and would be happy to introduce the change just for the sake of not having to fork.
Thanks, and sorry if my above comment wasn't totally nice, many projects are screwed up.

Please sign in to comment.