This is an automated email from the ASF dual-hosted git repository.

borinquenkid pushed a commit to branch 8.0.x-hibernate7
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 33775576e4aebd56b3c5ad7b191bfff7f421a5fe
Author: Walter B Duque de Estrada <[email protected]>
AuthorDate: Wed Jan 28 13:20:48 2026 -0600

    Rlike tested
---
 grails-data-hibernate7/core/build.gradle           |   7 ++
 .../grails/gorm/specs/RLikeHibernate7Spec.groovy   | 103 +++++++++++++++++++++
 .../hibernate/query/RegexDialectPatternSpec.groovy |   2 +-
 .../data/testing/tck/tests}/RLikeSpec.groovy       |  12 +--
 4 files changed, 117 insertions(+), 7 deletions(-)

diff --git a/grails-data-hibernate7/core/build.gradle 
b/grails-data-hibernate7/core/build.gradle
index 840f888c28..6d912f8671 100644
--- a/grails-data-hibernate7/core/build.gradle
+++ b/grails-data-hibernate7/core/build.gradle
@@ -81,8 +81,15 @@ dependencies {
         exclude group:'xml-apis', module:'xml-apis'
     }
 
+    testImplementation platform('org.testcontainers:testcontainers-bom:2.0.3')
     testImplementation 'org.postgresql:postgresql:42.7.5'
     testImplementation 'org.testcontainers:postgresql'
+    testImplementation 'com.mysql:mysql-connector-j:9.2.0'
+    testImplementation 'org.testcontainers:mysql'
+    testImplementation 'org.mariadb.jdbc:mariadb-java-client:3.5.2'
+    testImplementation 'org.testcontainers:mariadb'
+    testImplementation 'com.oracle.database.jdbc:ojdbc11:23.7.0.25.01'
+    testImplementation 'org.testcontainers:oracle-free'
     testImplementation 'org.testcontainers:spock'
     testImplementation 'org.jsr107.ri:cache-ri-impl:1.1.1'
 
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/RLikeHibernate7Spec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/RLikeHibernate7Spec.groovy
new file mode 100644
index 0000000000..af56ad8f84
--- /dev/null
+++ 
b/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/RLikeHibernate7Spec.groovy
@@ -0,0 +1,103 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.gorm.specs
+
+import org.testcontainers.oracle.OracleContainer
+
+import grails.gorm.annotation.Entity
+import org.testcontainers.containers.MariaDBContainer
+import org.testcontainers.containers.MySQLContainer
+import org.testcontainers.containers.PostgreSQLContainer
+import org.testcontainers.spock.Testcontainers
+import spock.lang.Shared
+import spock.lang.Unroll
+
+@Testcontainers
+class RLikeHibernate7Spec extends HibernateGormDatastoreSpec {
+
+    @Shared postgres = new PostgreSQLContainer("postgres:16")
+    @Shared mysql = new MySQLContainer("mysql:8.0")
+    @Shared mariadb = new MariaDBContainer("mariadb:10.11")
+    @Shared oracle = new OracleContainer("gvenzl/oracle-free:23-slim")
+
+    void setupSpec() {
+        manager.addAllDomainClasses([RlikeFoo])
+    }
+
+    void cleanupSpec() {
+        // Testcontainers @Testcontainers + @Shared handles stopping
+    }
+
+    @Unroll
+    void "test rlike works with #db"() {
+        given:
+        if (container != null && !container.isRunning()) {
+            container.start()
+        }
+
+        String url = container ? container.jdbcUrl : "jdbc:h2:mem:grailsDB"
+        String driver = container ? container.driverClassName : "org.h2.Driver"
+        String username = container ? container.username : "sa"
+        String password = container ? container.password : ""
+
+        // Reconfigure manager for this specific database
+        manager.cleanup() // Clean up previous session/datastore
+        manager.grailsConfig = [
+                'dataSource.url'           : url,
+                'dataSource.driverClassName': driver,
+                'dataSource.username'      : username,
+                'dataSource.password'      : password,
+                'dataSource.dbCreate'      : 'create-drop',
+                'hibernate.dialect'        : dialect,
+                'hibernate.hbm2ddl.auto'   : 'create',
+                'hibernate.show_sql'       : 'true',
+                'hibernate.format_sql'     : 'true',
+                'hibernate.id.new_generator_mappings': 'true'
+        ]
+        manager.setup(this.class) // Initialize with new config
+
+        // Use the same given data
+        new RlikeFoo(name: "ABC").save()
+        new RlikeFoo(name: "ABCDEF").save()
+        new RlikeFoo(name: "ABCDEFGHI").save(flush: true)
+
+        when:
+        manager.session.clear()
+        List<RlikeFoo> allFoos = RlikeFoo.findAllByNameRlike("ABCD.*")
+
+        then:
+        allFoos.size() == 2
+
+        where:
+        db           | container | dialect
+        "H2"         | null      | "org.hibernate.dialect.H2Dialect"
+        "Postgres"   | postgres  | "org.hibernate.dialect.PostgreSQLDialect"
+        "MySQL"      | mysql     | "org.hibernate.dialect.MySQLDialect"
+        "MariaDB"    | mariadb   | "org.hibernate.dialect.MariaDBDialect"
+        "Oracle"     | oracle    | "org.hibernate.dialect.OracleDialect"
+    }
+}
+
+@Entity
+class RlikeFoo {
+    String name
+    static mapping = {
+        id generator: 'identity'
+    }
+}
\ No newline at end of file
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/RegexDialectPatternSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/RegexDialectPatternSpec.groovy
index 25a6b1b51d..8bc2f600cd 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/RegexDialectPatternSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/RegexDialectPatternSpec.groovy
@@ -19,7 +19,7 @@ class RegexDialectPatternSpec extends Specification {
         where:
         dialect                  | expectedPattern
         new MySQLDialect()       | "?1 RLIKE ?2"
-        new MariaDBDialect()     | "?1 REGEXP ?2"
+        new MariaDBDialect()     | "?1 RLIKE ?2"
         new PostgreSQLDialect()  | "?1 ~ ?2"
         new OracleDialect()      | "REGEXP_LIKE(?1, ?2)"
         new H2Dialect()          | "REGEXP_LIKE(?1, ?2)"
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/RLikeSpec.groovy
 
b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/RLikeSpec.groovy
similarity index 85%
rename from 
grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/RLikeSpec.groovy
rename to 
grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/RLikeSpec.groovy
index 07dc293ae0..780238dbeb 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/grails/gorm/specs/RLikeSpec.groovy
+++ 
b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/RLikeSpec.groovy
@@ -16,19 +16,19 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package grails.gorm.specs
+package org.apache.grails.data.testing.tck.tests
 
 import grails.gorm.annotation.Entity
-import org.apache.grails.data.hibernate7.core.GrailsDataHibernate7TckManager
 import org.apache.grails.data.testing.tck.base.GrailsDataTckSpec
-import spock.lang.Ignore
+import spock.lang.IgnoreIf
 
-class RLikeSpec extends GrailsDataTckSpec<GrailsDataHibernate7TckManager> {
+@IgnoreIf({ System.getProperty("hibernate7.gorm.suite") == "true" })
+class RLikeSpec extends GrailsDataTckSpec {
     void setupSpec() {
         manager.addAllDomainClasses([RlikeFoo])
     }
 
-    void "test rlike works with H2"() {
+    void "test rlike works"() {
         given:
         new RlikeFoo(name: "ABC").save(flush: true)
         new RlikeFoo(name: "ABCDEF").save(flush: true)
@@ -46,4 +46,4 @@ class RLikeSpec extends 
GrailsDataTckSpec<GrailsDataHibernate7TckManager> {
 @Entity
 class RlikeFoo {
     String name
-}
\ No newline at end of file
+}

Reply via email to