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

create Postgres columns of type 'text' #21

Closed
medovina opened this issue Sep 12, 2014 · 3 comments
Closed

create Postgres columns of type 'text' #21

medovina opened this issue Sep 12, 2014 · 3 comments

Comments

@medovina
Copy link

Currently if a Go field has type 'string', modl gives the corresponding column the type 'varchar' with a fixed character limit that comes from the column's MaxSize, or 255 if MaxSize is unspecified.

Postgres has a type 'text' which stores strings of any length. In the interest of avoiding arbitrary limits, I think 'text' should be the default column type for a Go string field.

@jmoiron
Copy link
Owner

jmoiron commented Oct 1, 2014

I'd like there to be a much more generic and powerful approach towards the creation of a column, beyond just allowing for a type to be set; perhaps the ability to set some arbitrary SQL.

@jmoiron jmoiron closed this as completed in 5d9b4fb Oct 1, 2014
@jmoiron
Copy link
Owner

jmoiron commented Oct 1, 2014

You can override just the type like this:

table := dbm.TableFor(myobj)
column := table.ColMap("column_name")
column.SetSqlType("text")

You can now also do, eg:

column.SetSqlCreate("foo text NOT NULL DEFAULT md5sum(some_other_column)")

@ferhatelmas
Copy link

Please correct me if I'm wrong. We can only specify column name as a field tag and it's not possible to specify sql as a field tag. In addition to current way, having it might be more convenient. If you think so, I'm eager to help you.

Btw, thank you for the library.

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