kaleidos / grails-postgresql-extensions

Grails plugin to use postgresql native elements such as arrays, hstores,...
Apache License 2.0
78 stars 62 forks source link

String type and db type #52

Open olivermt opened 9 years ago

olivermt commented 9 years ago

Hi.

ArrayType with String becomes varchar[] now, where would I look to be able to get it to be text instead?

I have "user-type" type: org.hibernate.type.TextType, class: String in my gorm default mappings, but this does not seem to be used by the plugin.

ilopmar commented 9 years ago

Hi!

As you can see in the dialect file, the string array is mapped with varchar: https://github.com/kaleidos/grails-postgresql-extensions/blob/master/src/java/net/kaleidos/hibernate/PostgresqlExtensionsDialect.java#L27

You can subclass the dialect an override the definition of the array type for strings to use text instead of varchar.

Please let me know if this works for you.

ilopmar commented 9 years ago

Or even better, we could create a new TEXT_ARRAY that use text instead of varchar.

@Alotor, what do you think?

olivermt commented 9 years ago

It doesn't really matter I think, the implementation behind the scenes is 100% identical for varchar and text, and varchar[] gives a non-limited per-string size, so any kind of change should not be able to make a difference.

I am not going to close the issue if you want to keep discussing, but consider me satisfied.

Great plugin by the way! :)

Crossing my fingers that some of you might need postgis and add that to the database as well ;)

Alotor commented 9 years ago

I think maybe we can add an additional parameter to support text arrays. For example:

stringArray type:ArrayType, params: [type: String, asText: true]

I think this is cleaner and easier :smile: