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

Grails 7: grails-core: update domain inheritance tests #13840

Open
jamesfredley opened this issue Nov 15, 2024 · 5 comments
Open

Grails 7: grails-core: update domain inheritance tests #13840

jamesfredley opened this issue Nov 15, 2024 · 5 comments
Assignees

Comments

@jamesfredley
Copy link
Contributor

Issue description

Now that domain inheritance is restored with Groovy 4.0.24

https://github.com/search?q=org%3Agrails%20groovy-5106&type=code

@jdaugherty
Copy link
Contributor

FYI: https://issues.apache.org/jira/browse/GROOVY-10140 is what broke the DomainConstraintGettersSpec. I'm still researching. I have confirmed that if you put transient on both a getter & setter in groovy 3 , then the metaclass will show that property as transient. This support appears removed in Groovy 4.

@jdaugherty
Copy link
Contributor

Example groovy code that works in groovy 3 showing the property is transient:

	import java.lang.reflect.* 

	class Test {
		transient String somePropertyName

		transient String getSomeOtherProperty() { null }
		transient void setSomeOtherProperty(String ignored) { }
	}

	def testing = new Test()
	def metaClass = testing.metaClass
	System.out.println("Found Properties:")
	System.out.println(metaClass.getProperties().collect{ it.name } )

	System.out.println("Some Other Property Modifiers")

	def values = metaClass.getMetaProperty('someOtherProperty').modifiers
	System.out.println(Modifier.isTransient(values))

@jdaugherty
Copy link
Contributor

Upon further research, the following tests were straight out ignored in 6.2.x:

ensure only public non-static bool properties with getter and setter are constrained properties
ensure constrained bool method properties are only public ones with both getter and setter
ensure only public non-static inherited bool properties with getter and setter are constrained properties
ensure constrained inherited bool method properties are only public ones with both getter and setter
ensure only public non-static bool properties from trait with getter and setter are constrained properties
ensure constrained bool method properties from trait are only public ones with both getter and setter
ensure trait transient properties and methods are not validated
ensure trait transient methods and properties are not constrained

@jdaugherty
Copy link
Contributor

jdaugherty commented Dec 10, 2024

Concerning the transient keyword on a method in the DomainConstraintGettersSpec, since it doesn't work in 6.2.x on properties and did work on the method form, with the method form removed, these methods can be removed from the example classes.

@jdaugherty
Copy link
Contributor

The test DomainConstraintGettersSpec used the is{PropertyName} syntax instead of get{PropertyName}. Switching to the get syntax fixes the previously ignored non-trait tests.

For the traits, defining the transient field values on the trait instead of the domain still does not work. Currently it's expected to always define the transient field values on the domain so this is expected behavior for now.

jdaugherty added a commit to jdaugherty/grails-core that referenced this issue Dec 10, 2024
@jdaugherty jdaugherty self-assigned this Dec 10, 2024
@jdaugherty jdaugherty moved this from Todo to In Progress in Grails 7 Dec 10, 2024
jdaugherty added a commit that referenced this issue Dec 11, 2024
* #13840 - Add back @entity for GORM Inheritance

* #13690 - feedback - add tests using is form of little boolean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

2 participants