kaleidos / grails-postgresql-extensions

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

Ported to Grails 3.2 with support Hibernate 5.1.1.Final. #99

Closed donbeave closed 6 years ago

donbeave commented 7 years ago

This is PR for https://github.com/kaleidos/grails-postgresql-extensions/issues/90 issue.

I also include this fix inside: https://github.com/kaleidos/grails-postgresql-extensions/pull/94.

ilopmar commented 7 years ago

Thank you very much! I really need to find time to review all pending MRs and merge this.

BTW, it seems that the tests are failing using JDK 7 because the class is compiled with JDK 8.

Execution failed for task ':compileGroovy'.
> org/postgresql/util/PGobject : Unsupported major.minor version 52.0

Any thoughts?

donbeave commented 7 years ago

Fixed.

erichelgeson commented 7 years ago

I'll be testing this tonight with the latest dbm snapshots and let you know how it goes. Great to see this updated!

donbeave commented 7 years ago

@erichelgeson @ilopmar guys, do you need any help? I can help you to review PR in this project. Our company @scentbird (Scentbird, it's a perfume subscription service) use this plugin in production. We have some resources to maintain this plugin, just in case, if you guys need some help.

ilopmar commented 7 years ago

I you guys confirm that the plugin is working, at least a can release a RC1 version even if I don't have time to merge it.

erichelgeson commented 7 years ago

I did some light testing and IMO it's worthy of an RC1. Mappings seem to work fine and works with the latest dbm snapshot:

addColumn(tableName: "foo") {
    column(name: "data", type: "json") {
        constraints(nullable: "false")
    }
}
     Column     |            Type             | Modifiers 
----------------+-----------------------------+-----------
 id             | bigint                      | not null
 version        | bigint                      | not null
 data           | json                        | not null

Tested with Grails 3.2.2

ilopmar commented 7 years ago

Excellent, I'll try to release a RC1 during the day or the weekend. I'll post it here once it's released.

Thank you for the help guys. I really appreciate it :)

ilopmar commented 7 years ago

Published

compile 'org.grails.plugins:postgresql-extensions:5.0.0-RC1'

Thank you again for your help!

donbeave commented 7 years ago

Thank you!

Btw, do you want to merge it into master or you want to separate into the single branch?

ilopmar commented 7 years ago

I'll merge it into master and I'll create a new branch for Hibernate 4. But before that I need to merge some other pending PRs and migrate all the documentation to Asciidoctor.

donbeave commented 7 years ago

@ilopmar I can help you with Asciidoctor.

ilopmar commented 7 years ago

My idea was to first refactor everything (that's why I migrated almost all Java code to Groovy + @CompileStatic) and then update the documentation using Asciidoctor extracting most of the code from the tests.

erichelgeson commented 7 years ago

Just ran into an issue on RC1 - We're seeing when using dialect: net.kaleidos.hibernate.PostgresqlExtensionsDialect and having sequence_per_table true (default) it is trying to use the default hibernate_sequence (sqllogging: Hibernate: select nextval ('hibernate_sequence')) - I'd expect it to use select nextval('role_sequence') as it did previously.

If I do a dbm-grom-diff it wants to create the hibernate_sequence and drop the existing ones.

I can temporarily work around it with: id generator: 'native', params: [sequence: 'seq_role']

Setting a breakpoint in PostgresqlExtensionsDialect it doesn't even look like it's being called - Now i'm wondering if my tests were only working with the default dialect (if it knows about json types)

ilopmar commented 7 years ago

I've been debugging the issue and the method in the dialect is not executed. That's why there's only one sequence for all the tables. I'm trying to figure it out why it's not called and what I need to do to be executed. If you have some suggestions, please let me know.

ilopmar commented 7 years ago

@erichelgeson How are you adding the workaround, in the mapping block?

    static mapping = {
        id generator: 'native', params: [sequence: 'seq_role']
    }

This is not creating the sequence during the start up of the application.

erichelgeson commented 7 years ago

I removed the plugin, used default pg dialect, and used the mapping block yes. My migration already had the seq from my 3.1 app and this mapping allowed me to use them.