H2 2.x Upgrade Padding UUIDs with spaces

Hello all!

Hopefully this is the final hurdle in the spring / hibernate / h2 upgrade for core. The question is related to this PR: TRUNK-6332: Hibernate 6.x and spring 6.x upgrade by k4pran · Pull Request #5062 · openmrs/openmrs-core · GitHub

After upgrading to h2 2.x the behaviour for UUIDs has changed and is breaking this test

In the liquibase changeset we define the length as 38

	<column name="uuid" type="CHAR(38)">
		<constraints nullable="false" unique="true"/>
	</column>

It used to be the case that if we passed a 36 character UUID it would be length 36, but now H2 seems to pad the end with spaces to force the length to 38.

You can see this behaviour in the h2 documentation

If my understanding is correct, we generally use 36-length UUIDs, and the 38-length is to support MSSQL. I also think H2 is only used for tests, and we already use H2LessStrictDialect to custom map UUIDs here.

H2LessStrictDialect doesn’t come into play in these specific tests, so my question is, can I either trim the result in the test, or update the liquibase xml to define it as a VARCHAR? Or any other suggestions?

If we trimmed the result in the test, will it pass when run against mysql or postgresql? Jira

Yea i think they should still pass as it only trims any added spaces, without spaces it would behave the same and just compare the 36-length uuids

Then in that case i would vote yes to just trimming the test results and we move on.

2 Likes