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

add ability to set schema names #11

Closed aeischeid closed 11 years ago

aeischeid commented 11 years ago

we were looking into using this plugin on our project Thanks for putting it out there. It looks pretty promising, but this is a small addition that would make it better for us.

ilopmar commented 11 years ago

Thank you very much for your pull request. Before merge it I would like to know how to use it to update the documentation with this new feature. Is it necessary to set some property in DataSource.groovy to define the new schema name?

Could you please add an example?

Regards, Iván.

aeischeid commented 11 years ago

honsetly I am not entirely certain, but I think this is handled by the mapping block in a domain class.

static mapping = {
    table name:"rpt_animal", schema:"warehouse"
    id column:'animal_key', params: ['schemaName': 'warehouse']
ilopmar commented 11 years ago

Hi Aaron,

I've doing some tests and I think your patch is not necessary and everythings it's working propertly. I haven't applied your patch and I've defined the following mapping in a domain class:

static mapping = {
    table schema:"warehouse"
}

Now, if I execute schema-export I get:

drop table warehouse.test_string cascade;
create table warehouse.test_string (id int8 not null, version int8 not null, string_array varchar[] not null, primary key (id));

As you can see the schema warehouse is applied.

I've tried with Grails 2.1.5. Which version of grails have you used?

Regards, Iván.

Alotor commented 11 years ago

Hi,

I've tested the code and the problem is the sequence related to the domain-class table.

Couldn't you get the schema name from the "table" mapping? I think it's a bit repetitive to have the schema-name twice.

Regards,

aeischeid commented 11 years ago

@lmivan I am using grails 2.2.3

@Alotor I think that is correct; That the reason we had this in our previous postgres dialect extension was related to the sequence. There may be a better way to do this, but what I know now is that if this bit of code isn't in then our app fails to startup

aeischeid commented 11 years ago

@Alotor I have been digging just a bit and can't really figure out what you meant by "get the schema name from the 'table' mapping?" could you explain that a little more.

Alotor commented 11 years ago

When you define the "mappings" like:

static mapping = {
    table name:"rpt_animal", schema:"warehouse"
}

You're already defining the schema in the "table" attribute inside the mapping DSL. I think we can access that value instead of getting a new param.

ilopmar commented 11 years ago

@alotor, I've been digging into Hibernate's code and I think it's not possible to get the schema name from the grails mapping. I can tell you what I've done next wednesday at the office in case you can try it. If you don't get anything, then we can accept the pull request.

Alotor commented 11 years ago

We merged your pull request because we were investigating and we didn't find a better way of doing it.

Thanks for your contribution :smile:

aeischeid commented 11 years ago

Cool, Thanks guys! I'll look into helping more as I get more experience with this plugin. Some of the recent Postgres json stuff is pretty sweet looking but for now grails hides that all away from me :(

ilopmar commented 11 years ago

Currently we're working on the store support in this branch https://github.com/kaleidos/grails-postgresql-extensions/tree/hstore. For the moment we can read and write into hstore and we're working on criterias.

As soon as we finish this support we'll start working on the json support. Any collaboration is appreciated.

Regards, Iván.