-
-
Notifications
You must be signed in to change notification settings - Fork 966
7.1.x AutoTmestamp Enhancements + grails.importGrailsAnnotations GrailsExtension #15118
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
base: 7.1.x
Are you sure you want to change the base?
7.1.x AutoTmestamp Enhancements + grails.importGrailsAnnotations GrailsExtension #15118
Conversation
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Show resolved
Hide resolved
…erties will only be marked dirty if other updates exist. This mimics the behavior in hibernate. Fixes apache#15120
|
Per the weekly meeting, we'll merge this into 7.1. The vote to create that branch is going now - once 72 hrs have passed, we'll create the branch. |
|
@codeconsole Can you update this PR now that you've made your mongo update date fixes? |
… is now handled in the EntityPersister
Done |
|
I've updated 7.1.x with the latest 7.0.x changes. Can you please merge 7.1.x into this PR so the changes are reflected? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My largest problem is the breaking change with the isDevelopmentMode(). We need a better solution here. Can you give your reasoning for disabling the caching in development mode?
grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/timestamp/AuditorAware.java
Outdated
Show resolved
Hide resolved
| } | ||
| else { | ||
| // Check if property has @CreatedDate or @LastModifiedDate annotations | ||
| if (AutoTimestampUtils.hasAutoTimestampAnnotation(persistentProperty)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't constraints be added for the auditor type? It's perfectly reasonable if the auditor is a String, to set a max string (i.e. if you wanted a value greater than 255)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true, as auditor can be different types, and constraints influence the database schema.
...ls-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AutoTimestampUtils.java
Outdated
Show resolved
Hide resolved
grails-datamapping-core/src/main/groovy/grails/gorm/annotation/CreatedBy.java
Show resolved
Hide resolved
grails-datamapping-core/src/main/groovy/grails/gorm/annotation/LastModifiedBy.java
Show resolved
Hide resolved
| /** | ||
| * Enum representing the type of auto-timestamp annotation on a property | ||
| */ | ||
| static enum AutoTimestampType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Can we pull this into it's own file?
- Is "AutoTimestamp" really a good name for createdBy / updatedBy? Would Tracked or TrackedEntityType be a better name?
...ls-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AutoTimestampUtils.java
Outdated
Show resolved
Hide resolved
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Show resolved
Hide resolved
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Show resolved
Hide resolved
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Show resolved
Hide resolved
@jdaugherty You are looking at it from the wrong perspective. I am introducing caching when not in development mode. The current implementation has no caching. The performance benefit is so negligible that I suspect you wouldn't even notice. |
|
We should just always cache. We don't need the dependency that way. |
grails-datamapping-core/src/main/groovy/grails/gorm/annotation/AutoTimestamp.java
Outdated
Show resolved
Hide resolved
grails-datamapping-core/src/main/groovy/grails/gorm/annotation/CreatedBy.java
Show resolved
Hide resolved
grails-datamapping-core/src/main/groovy/grails/gorm/annotation/CreatedDate.java
Show resolved
Hide resolved
grails-datamapping-core/src/main/groovy/grails/gorm/annotation/LastModifiedBy.java
Show resolved
Hide resolved
grails-datamapping-core/src/main/groovy/grails/gorm/annotation/LastModifiedDate.java
Show resolved
Hide resolved
...groovy/org/grails/datastore/gorm/validation/constraints/eval/DefaultConstraintEvaluator.java
Show resolved
Hide resolved
| } | ||
| else { | ||
| // Check if property has @CreatedDate or @LastModifiedDate annotations | ||
| if (AutoTimestampUtils.hasAutoTimestampAnnotation(persistentProperty)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true, as auditor can be different types, and constraints influence the database schema.
| properties = list ? domainModelService.getListOutputProperties(domainClass) : domainModelService.getInputProperties(domainClass, | ||
| exclusionType == ExclusionType.Input ? exclusionsInput : exclusionsDisplay) | ||
| exclusionType == ExclusionType.Input ? exclusionsInput : exclusionsDisplay, | ||
| exclusionType == ExclusionType.Input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getInputProperties(PersistenProperty, List<String>, boolean) is not part of the DomainModelService interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is no longer implementing getInputProperties(PersistentEntity, List) from the DomainModelService interface.
Introduce
@CreatedDate,@LastModifiedDate,@CreatedBy, and@LastModifiedBysimilar to Spring DataIntroduce grails.importGrailsCommonAnnotations to automatically import common grails annotations and jakarta.validation.constraints.*
build.gradle
allows the following with no imports