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

Ability to log actual table name and column name instead of property name and domain class name respectively #122

Open
dmahapatro opened this issue Aug 18, 2016 · 7 comments

Comments

@dmahapatro
Copy link
Contributor

dmahapatro commented Aug 18, 2016

It will an useful enhancement if we can add configurations like grails.plugin.auditLog.logTableName and grails.plugin.auditLog.logColumnName to capture the actual table name and column name respectively.

They (actual names and domain class property names) can be mutually exclusive or both inclusive if required. That can also be driven by a config item. That is, either we have one or the other or we can have both properties and actual names. Thoughts?

For example, considering the below Book domain class;

class Book {
    String name

    static mapping = {
        table 'BOOK'
        name column: 'BOOK_NAME'
    }
}

We can have either Book as the CLASS_NAME in the AUDIT_LOG table or BOOK (actual table name) as CLASS_NAME in AUDIT_LOG table. It would be nice if we capture both. That would need adding a new column to the AUDIT_LOG table named TABLE_NAME. Same goes with PROPERTY_NAME and COLUMN_NAME

@robertoschwald
Copy link
Contributor

Requirement:

  1. orm-independent way
  2. independent of mapping config

@dmahapatro
Copy link
Contributor Author

@robertoschwald Let me know if you want me to send a PR. You mentioned you think about the table name column over the weekend, but if you want I can send the changes related to COLUMN_NAME column.

@robertoschwald
Copy link
Contributor

Would be great if you can form a PR.

@dmahapatro
Copy link
Contributor Author

Sure. Will work on it over the weekend.

dmahapatro pushed a commit to dmahapatro/grails-audit-logging-plugin that referenced this issue Aug 21, 2016
@dmahapatro
Copy link
Contributor Author

I have a working solution for COLUMN_NAME as property name in my forked repo. I have an integration test which fails because I am unable to set the config property in integration test.

This test should pass because I have used it in a similar way in other applications with Grails 3.1.9. I will look into it more.

@robertoschwald
Copy link
Contributor

Any news on this? Will you provide a PR?

@robertoschwald
Copy link
Contributor

@dmahapatro I think setting in applicationContext config is too late at that point. See the new TruncateSpec how I change it directly in the listeners.
https://github.com/robertoschwald/grails-audit-logging-plugin/blob/master/audit-test/src/integration-test/groovy/test/AuditTruncateSpec.groovy#L136

Please mark it the same way as I did to avoid people to do this nasty thing in real live. thx.

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

2 participants