bito-code-review[bot] commented on PR #15436:
URL: https://github.com/apache/grails-core/pull/15436#issuecomment-3948505187

   <!-- Bito Reply -->
   Yes, that's a valid concern. The query filters tables based on 
`row_count_estimate > 0`, but since H2's `row_count_estimate` is an 
approximation, tables with actual rows might show 0 and be skipped, leaving 
test data behind. To address this, consider removing the `row_count_estimate > 
0` filter to truncate all tables in the schema, as truncating empty tables is 
harmless and ensures complete cleanup.
   
   
**grails-testing-support-cleanup-h2/src/main/groovy/org/apache/grails/testing/cleanup/h2/H2DatabaseCleaner.groovy**
   ```
   String query = "SELECT table_name, row_count_estimate FROM 
information_schema.tables WHERE table_schema = '${schemaName}'" as String
               sql.eachRow(query) { GroovyResultSet row ->
                   String tableName = row['table_name'] as String
                   stats.addTableRowCount(tableName, row['row_count_estimate'] 
as Long)
                   log.debug('Truncating table: {}', tableName)
                   sql.executeUpdate("TRUNCATE TABLE \"${tableName}\"" as 
String)
               }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to