Repository navigation
test(hibernate7): run the where query functions on a SQL Server container - #16962
borinquenkid wants to merge 5 commits into
Conversation
…n a SQL Server container Transact-SQL has no boolean value for a predicate, so the like that rlike falls back to rendered as 'name LIKE ?=?' and failed with 'Incorrect syntax near =' on a real SQL Server. It is now the condition of a CASE that gives a bit, which the query compares with true. DatabaseContainers gains SQL Server, and the two rlike features run on it. Sybase, Db2 for IBM i and Db2 for z/OS cannot run in a container, so their rows are not changed and each constant says that no test runs it. Refs #16881 Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
…unctions-sqlserver-8.0.x
…iner SQL Server was the database left that no dialect spec covered. The date functions, the fraction comparison and the empty list (a read, and a bulk update and delete) all match what the other databases return on a real SQL Server. Refs #16932 Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
jamesfredley
left a comment
There was a problem hiding this comment.
Not approving. Adding the web datastore module turns on an interceptor that closes the outer session during an include, and that leaves a session bound to the first thread of an asynchronous request.
| runtimeOnly project(':grails-data-mongodb-ext'), { | ||
| // Include MongoDB groovy extensions for applications | ||
| } | ||
| runtimeOnly project(':grails-datastore-web'), { |
There was a problem hiding this comment.
This dependency registers the open-session interceptor. An include reuses the outer session, and the interceptor then unbinds and disconnects it before the outer transaction finishes. An asynchronous request binds a session to the first thread and never releases it when the work moves to another thread, so a later request can see that session. Track participation, and release the session when asynchronous handling starts, before this dependency is on by default.
|
The line you commented on, What this pull request adds is the commit 1711fef: the where query functions run on a SQL Server container, plus the stacked branch of the SQL Server rlike change it builds on. It does not touch the MongoDB plugin or the open-session interceptor. The two problems you describe are real questions about that change: an include that reuses the outer session while the interceptor unbinds and disconnects it, and an asynchronous request that binds a session to its first thread. I have not run either. They belong on the pull request or issue of the MongoDB change, not on this stack, so I will not change anything here for them. If you would like, I can open an issue with the two cases you wrote so they are tracked. |
matrei
left a comment
There was a problem hiding this comment.
Reviewed at 1711fef (base fix/h7-where-query-functions-8.0.x, #16816's head branch). This PR's own change is that commit: seven lines in WhereQueryFunctionsDialectSpec. The rest of the 126 files GitHub shows come from the branch of #16954, merged at e5397ed, one commit before its head, and from the history of #16816 before its latest merges of 8.0.x: this branch has not merged #16816's head (2c6b447). The PR is labelled no ci.
What I ran locally:
WhereQueryFunctionsDialectSpecat this head, on an x86_64 machine with Docker: all 14 rows pass, the four SQL Server rows included, and so does the Db2 row, which the arm64 machine of the description skips. Db2 took about 150 seconds to start, SQL Server about 55.
For Hibernate 7, the branch is right: the spec exists only in #16816 and the SQL Server container only in #16954, so retargeting 8.0.x once both are merged, as the description plans, is the way it can go in. The change only adds rows to a test, so it needs one approval. The two reviewers of the rule in the dev@ thread are for a change that alters a result.
On James's review: the line he commented on, runtimeOnly project(':grails-datastore-web') in grails-data-mongodb/grails-plugin/build.gradle, is not part of this change, as you wrote. It came with #16899 on 7.0.x and reached 8.0.x through the merge-ups. His two cases, an include that reuses the outer session and an asynchronous request, are about that change, so the issue you offered, linked to #16899, is the place for them.
Suggestions
startOnnow starts a container that is not running, so the Oracle and Db2 feature's ownif (!container.isRunning()) { container.start() }can go.- The spec creates Postgres, MySQL and MariaDB containers of its own.
RLikeHibernate7Spec,NativeIdGeneratorHibernate7SpecandSharedJoinTableHibernate7SpecuseDatabaseContainers.POSTGRES,MYSQLandMARIADB, which a test JVM starts once for all of them. Using those here too would save starting a second container of each.
sbglasius
left a comment
There was a problem hiding this comment.
This an AI assisted review
Reviewed at 1711fef. This PR's own change is that one commit: seven lines in WhereQueryFunctionsDialectSpec, which add a SQL Server row to the three features that run on every database, and make startOn start a container that is not running. The other files in the diff come from #16954 (merged in at e5397ed) and from the history of #16816. The test only uses public GORM APIs (DetachedCriteria.list, updateAll, deleteAll), and there is no production change.
I ran ./gradlew :grails-data-hibernate7-core:test --tests "grails.gorm.tests.detachedcriteria.WhereQueryFunctionsDialectSpec" on x86_64 with Docker. All 14 rows passed and none were skipped: the four SQL Server rows, and the Oracle and Db2 rows too.
This closes the gap #16932 describes: an empty list in a function comparison (upper(name) in []) on a read and in a bulk update and delete, now on SQL Server too.
Two small notes, neither blocking:
- The base has moved since this branch last merged it.
fix/h7-where-query-functions-8.0.xis now at 85c8df3, and this branch does not contain it. That will sort itself out when this PR is retargeted to 8.0.x, but the SQL Server rows are worth running once more after the retarget. - +1 to matrei's first suggestion.
startOnnow starts the container itself, so theif (!container.isRunning())block in the Oracle and Db2 feature is no longer needed.
| @Shared MariaDBContainer mariadb = new MariaDBContainer('mariadb:10.11') | ||
| @Shared oracle = DatabaseContainers.ORACLE | ||
| @Shared db2 = DatabaseContainers.DB2 | ||
| @Shared sqlServer = DatabaseContainers.SQL_SERVER |
There was a problem hiding this comment.
The class Javadoc above (line 37) still lists the databases without SQL Server. Maybe add something like: "SQL Server runs every feature; its image is amd64 only, so on arm64 it runs under emulation and is slow to start." That way a reader knows why a SQL Server row can take minutes on an arm machine.
| 'Postgres' | postgres | ||
| 'MySQL' | mysql | ||
| 'MariaDB' | mariadb | ||
| 'SQL Server' | sqlServer |
There was a problem hiding this comment.
Nit: 'SQL Server' is wider than the db column, so the | no longer lines up with the rows above it. The same happens at lines 144 and 170. Padding db, 'Postgres', 'MySQL' and 'MariaDB' to the width of 'SQL Server' keeps the three tables aligned.
…h7-where-functions-sqlserver-8.0.x
|
Merged |
Runs the where query functions of
WhereQueryFunctionsDialectSpecon a real SQL Server, the database the dialect specs did not cover. Closes #16932.The reviewer of #16816 wrote that an empty list in a function comparison "still throws on a database that rejects an empty IN list". The empty list was run on PostgreSQL, MySQL, MariaDB and Oracle; SQL Server was the database left. On a real SQL Server, every row passes as it does on the others:
year,month,day,hour,minute,second) on a read and in a bulk delete,length(name) > 2.5,upper(name) = 3.5) on a read and in a bulk delete,upper(name) in []) and a subquery without projection, on a read and in a bulk update and delete.No defect found, so no production code changes. Test code only.
Stacked twice, on purpose: the spec exists only in #16816, so this PR's base is #16816's branch (
fix/h7-where-query-functions-8.0.x); the SQL Server container comes from #16954, whose branch is merged into this one, so its commits show here until #16954 lands. After #16816 and #16954 merge, this retargets 8.0.x and shows only its own commit.Verified locally on a real SQL Server container (14 rows pass, the Db2 row skips on this arm machine); CodeNarc, Checkstyle and rat are clean. CI is off (
no ci). Two reviewers (matrei and codeconsole), as 8.0.x is released.https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL