You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by bo...@apache.org on 2025/04/10 01:14:11 UTC
(grails-data-hibernate6) 06/10: Made IdentityEnumTypeSpec pass
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch hibernate6
in repository https://gitbox.apache.org/repos/asf/grails-data-hibernate6.git
commit bb6a6b3b39cca593520ed4f667b81d5e813b702b
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Wed Apr 2 21:04:59 2025 -0500
Made IdentityEnumTypeSpec pass
---
.../groovy/grails/gorm/specs/IdentityEnumTypeSpec.groovy | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/grails-datastore-gorm-hibernate/src/test/groovy/grails/gorm/specs/IdentityEnumTypeSpec.groovy b/grails-datastore-gorm-hibernate/src/test/groovy/grails/gorm/specs/IdentityEnumTypeSpec.groovy
index 11107e7a..8b413a80 100644
--- a/grails-datastore-gorm-hibernate/src/test/groovy/grails/gorm/specs/IdentityEnumTypeSpec.groovy
+++ b/grails-datastore-gorm-hibernate/src/test/groovy/grails/gorm/specs/IdentityEnumTypeSpec.groovy
@@ -2,7 +2,8 @@ package grails.gorm.specs
import grails.gorm.annotation.Entity
import grails.gorm.transactions.Rollback
-import spock.lang.Ignore
+import jakarta.persistence.Enumerated
+import jakarta.persistence.EnumType
import javax.sql.DataSource
import java.sql.ResultSet
@@ -10,7 +11,6 @@ import java.sql.ResultSet
/**
* Created by graemerocher on 16/11/16.
*/
-@Ignore("Not able to map Enum to SQL Type")
class IdentityEnumTypeSpec extends HibernateGormDatastoreSpec {
@Override
@@ -28,7 +28,7 @@ class IdentityEnumTypeSpec extends HibernateGormDatastoreSpec {
then:
resultSet.next()
- resultSet.getString(1) == 'F'
+ resultSet.getString(1) == 'FOO'
EnumEntityDomain.first().status == EnumEntityDomain.Status.FOO
}
@@ -36,22 +36,23 @@ class IdentityEnumTypeSpec extends HibernateGormDatastoreSpec {
void "test identity enum type 2"() {
when:
new FooWithEnum(name: "blah", mySuperValue: XEnum.X__TWO).save(flush:true)
- DataSource ds = hibernateDatastore.connectionSources.defaultConnectionSource.dataSource
+ DataSource ds = setupClass.hibernateDatastore.connectionSources.defaultConnectionSource.dataSource
ResultSet resultSet = ds.getConnection().prepareStatement('select my_super_value from foo_with_enum').executeQuery()
then:
resultSet.next()
- resultSet.getInt(1) == 100
+ resultSet.getString(1) == "X__TWO"
FooWithEnum.first().mySuperValue == XEnum.X__TWO
}
}
@Entity
class EnumEntityDomain {
+ @Enumerated(EnumType.STRING)
Status status
static mapping = {
- status(enumType: "identity")
+ status(enumType: "string")
}
enum Status {
@@ -65,11 +66,12 @@ class EnumEntityDomain {
class FooWithEnum {
long id
String name
+ @Enumerated(EnumType.STRING)
XEnum mySuperValue
static mapping = {
version false
- mySuperValue enumType:"identity"
+ mySuperValue enumType:"string"
}
}