Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix types handling #467

Merged
merged 9 commits into from
Apr 13, 2023
Merged

Fix types handling #467

merged 9 commits into from
Apr 13, 2023

Conversation

filipelautert
Copy link
Collaborator

Restore previous behavior and handle diff when the size/length of a field changes.

@filipelautert filipelautert self-assigned this Mar 14, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2023

Testing These Changes

To test this PR, use the artifacts attached to the latest CI build

Artifacts Available:

  • liquibase-hibernate-artifacts: Zip containing the .jar file to test
  • test-reports-*: Detailed automated test results

Download with liquibase-sdk-maven-plugin

Alternately, you can use the Liquibase SDK Maven Plugin

Download the artifacts

mvn org.liquibase.ext:liquibase-sdk-maven-plugin:0.10.20:download-snapshot-artifacts -Dliquibase.sdk.repo=liquibase/liquibase-hibernate -Dliquibase.sdk.branchSearch=liquibase:fix_types_handling -Dliquibase.sdk.downloadDirectory=download -Dliquibase.sdk.artifactPattern=*-artifacts -Dliquibase.sdk.unzipArtifacts=true

Install to your local maven cache

mvn org.liquibase.ext:liquibase-sdk-maven-plugin:0.10.20:install-snapshot -Dliquibase.sdk.repo=liquibase/liquibase-hibernate -Dliquibase.sdk.branchSearch=liquibase:fix_types_handling

@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2023

Test Results

36 files  ±0  36 suites  ±0   53s ⏱️ +2s
21 tests ±0  21 ✔️ ±0  0 💤 ±0  0 ±0 
84 runs  ±0  84 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit c4c391c. ± Comparison against base commit 76151df.

♻️ This comment has been updated with latest results.

@javaboy79
Copy link

@filipelautert My test produces an NPE
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "liquibase.structure.core.DataType.getColumnSize()" is null at liquibase.ext.hibernate.diff.ChangedColumnChangeGenerator.handleSizeChange(ChangedColumnChangeGenerator.java:47) at liquibase.ext.hibernate.diff.ChangedColumnChangeGenerator.handleTypeDifferences(ChangedColumnChangeGenerator.java:33) at liquibase.diff.output.changelog.core.ChangedColumnChangeGenerator.fixChanged(ChangedColumnChangeGenerator.java:66) at liquibase.diff.output.changelog.ChangeGeneratorChain.fixChanged(ChangeGeneratorChain.java:137) at liquibase.diff.output.changelog.ChangeGeneratorFactory.fixChanged(ChangeGeneratorFactory.java:117) at liquibase.diff.output.changelog.DiffToChangeLog.generateChangeSets(DiffToChangeLog.java:282) at liquibase.diff.output.changelog.DiffToChangeLog.printNew(DiffToChangeLog.java:230) at liquibase.diff.output.changelog.DiffToChangeLog$1.run(DiffToChangeLog.java:149) ... 38 more

@filipelautert
Copy link
Collaborator Author

I should have tested with fields that don't have sizes. Well, fixed now! Can you give it another try @javaboy79 ? Thank you!

@javaboy79
Copy link

This is mostly working now. However, I am still ending up with items in my diff that should not be there. timestamp types are always listed for modify. I tried applying the change, and still, they are listed again on the next diff. So, clearly, something is still wrong with the diff.

All other reported types are now cleared from the diff.

@javaboy79
Copy link

@filipelautert I feel like you were making good progress on this. Do you have any feedback or fix for my last comment?

@filipelautert
Copy link
Collaborator Author

Hello @javaboy79 ! I think there is no other way but creating a list of type exclusions for the size checks.
In the end this is good, as before it was excluding everything, but now we can choose what to exclude.
I went ahead and added timestamp. If there is anything else let me know and I can add to the list. I want to finish this in time for the next release.

@javaboy79
Copy link

Another NPE:
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "liquibase.structure.core.DataType.getColumnSize()" is null at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:207) at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:96) at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:90) at liquibase.command.core.InternalDiffChangelogCommandStep.run(InternalDiffChangelogCommandStep.java:63) at liquibase.command.CommandScope.execute(CommandScope.java:172) ... 29 more Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "liquibase.structure.core.DataType.getColumnSize()" is null at liquibase.diff.output.changelog.DiffToChangeLog$1.run(DiffToChangeLog.java:190) at liquibase.Scope.lambda$child$0(Scope.java:180) at liquibase.Scope.child(Scope.java:189) at liquibase.Scope.child(Scope.java:179) at liquibase.Scope.child(Scope.java:158) at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:143) ... 33 more Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "liquibase.structure.core.DataType.getColumnSize()" is null at liquibase.ext.hibernate.diff.ChangedColumnChangeGenerator.handleSizeChange(ChangedColumnChangeGenerator.java:47) at liquibase.ext.hibernate.diff.ChangedColumnChangeGenerator.handleTypeDifferences(ChangedColumnChangeGenerator.java:33) at liquibase.diff.output.changelog.core.ChangedColumnChangeGenerator.fixChanged(ChangedColumnChangeGenerator.java:66) at liquibase.diff.output.changelog.ChangeGeneratorChain.fixChanged(ChangeGeneratorChain.java:137) at liquibase.diff.output.changelog.ChangeGeneratorFactory.fixChanged(ChangeGeneratorFactory.java:117) at liquibase.diff.output.changelog.DiffToChangeLog.generateChangeSets(DiffToChangeLog.java:282) at liquibase.diff.output.changelog.DiffToChangeLog.printNew(DiffToChangeLog.java:230) at liquibase.diff.output.changelog.DiffToChangeLog$1.run(DiffToChangeLog.java:149)

@filipelautert
Copy link
Collaborator Author

Hm.. this time the problem was down there on liquibase core. Seems I passed something with null that could not be handled .
I believe I fixed it, here we go again...

@filipelautert
Copy link
Collaborator Author

filipelautert commented Apr 3, 2023

@javaboy79 When you have some time, it's ready for another run. Thanks!

@javaboy79
Copy link

javaboy79 commented Apr 5, 2023 via email

@filipelautert filipelautert requested a review from MalloD12 April 13, 2023 11:55
@filipelautert filipelautert merged commit bdee55e into main Apr 13, 2023
@filipelautert
Copy link
Collaborator Author

Hello @javaboy79 - I'm merging this as is for 4.21.0 that is going to be out today. If the problem persists let's continue from here 👍

@filipelautert filipelautert deleted the fix_types_handling branch April 13, 2023 15:41
@javaboy79
Copy link

@filipelautert Thank you for your efforts here! This is looking really good. Today I was able to pull 4.21.1 into my project and the diff produced actually found and correctly reported a discrepancy on one of my varchar lengths. This is great! However, as far as I can see, there is one problem left...

The diff is also reporting false positives on my unique indexes. Mind you, this is only happening for unique indexes. Other indexes seem fine.

e.g. (names obfuscated)
@Table( indexes = { @Index(name = "my_id_index", columnList = "id", unique = true), })

Even though the db already shows this as unique, the diff produces the following:
<changeSet author="user (generated)" id="1681760762251-3"> <dropUniqueConstraint constraintName="my_id_index" tableName="xxx"/> </changeSet>

@javaboy79
Copy link

@filipelautert This is also happening on unique constraints that were previously generated by the column annotation:
@Column(unique = true)
These are similarly being reported as a drop by the diff.

@filipelautert
Copy link
Collaborator Author

filipelautert commented Apr 18, 2023

@javaboy79 thanks! I'll create another PR until tomorrow and will tag you there.

@javaboy79
Copy link

@filipelautert Looks like it has already been reported. #479

benkard pushed a commit to benkard/mulkcms2 that referenced this pull request May 11, 2023
This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [flow-bin](https://github.com/flowtype/flow-bin) ([changelog](https://github.com/facebook/flow/blob/master/Changelog.md)) | devDependencies | minor | [`^0.203.0` -> `^0.206.0`](https://renovatebot.com/diffs/npm/flow-bin/0.203.1/0.206.0) |
| [org.liquibase.ext:liquibase-hibernate5](https://github.com/liquibase/liquibase-hibernate/wiki) ([source](https://github.com/liquibase/liquibase-hibernate)) | build | minor | `4.20.0` -> `4.21.1` |
| [org.liquibase:liquibase-maven-plugin](http://www.liquibase.org/liquibase-maven-plugin) ([source](https://github.com/liquibase/liquibase)) | build | minor | `4.20.0` -> `4.21.1` |
| [org.jsoup:jsoup](https://jsoup.org/) ([source](https://github.com/jhy/jsoup)) | compile | minor | `1.15.4` -> `1.16.1` |
| [com.vladsch.flexmark:flexmark-all](https://github.com/vsch/flexmark-java) | compile | patch | `0.64.0` -> `0.64.4` |
| [com.diffplug.spotless:spotless-maven-plugin](https://github.com/diffplug/spotless) | build | minor | `2.35.0` -> `2.36.0` |
| [io.quarkus:quarkus-maven-plugin](https://github.com/quarkusio/quarkus) | build | patch | `2.16.6.Final` -> `2.16.7.Final` |
| [io.quarkus:quarkus-universe-bom](https://github.com/quarkusio/quarkus-platform) | import | patch | `2.16.6.Final` -> `2.16.7.Final` |
| [org.apache.maven.plugins:maven-enforcer-plugin](https://maven.apache.org/enforcer/) | build | minor | `3.2.1` -> `3.3.0` |

---

### Release Notes

<details>
<summary>flowtype/flow-bin</summary>

### [`v0.206.0`](flow/flow-bin@f1c1fe9...7bf1c0e)

[Compare Source](flow/flow-bin@f1c1fe9...7bf1c0e)

### [`v0.205.1`](flow/flow-bin@7b34b50...f1c1fe9)

[Compare Source](flow/flow-bin@7b34b50...f1c1fe9)

### [`v0.205.0`](flow/flow-bin@2b838b7...7b34b50)

[Compare Source](flow/flow-bin@2b838b7...7b34b50)

### [`v0.204.1`](flow/flow-bin@283b669...2b838b7)

[Compare Source](flow/flow-bin@283b669...2b838b7)

### [`v0.204.0`](flow/flow-bin@5e0645d...283b669)

[Compare Source](flow/flow-bin@5e0645d...283b669)

</details>

<details>
<summary>liquibase/liquibase-hibernate</summary>

### [`v4.21.1`](https://github.com/liquibase/liquibase-hibernate/releases/tag/v4.21.1)

[Compare Source](liquibase/liquibase-hibernate@v4.21.0...v4.21.1)

Support for Liquibase 4.21.1.

**Full Changelog**: liquibase/liquibase-hibernate@v4.20.0...v4.21.1

### [`v4.21.0`](https://github.com/liquibase/liquibase-hibernate/releases/tag/v4.21.0)

[Compare Source](liquibase/liquibase-hibernate@v4.20.0...v4.21.0)

Support for Liquibase 4.21.0.

#### What's Changed

-   Bump snakeyaml from 1.33 to 2.0 by [@&#8203;dependabot](https://github.com/dependabot) in liquibase/liquibase-hibernate#462
-   Bump spring.version from 6.0.5 to 6.0.6 by [@&#8203;dependabot](https://github.com/dependabot) in liquibase/liquibase-hibernate#464
-   Bump maven-compiler-plugin from 3.10.1 to 3.11.0 by [@&#8203;dependabot](https://github.com/dependabot) in liquibase/liquibase-hibernate#461
-   Fix snyk warning by [@&#8203;filipelautert](https://github.com/filipelautert) in liquibase/liquibase-hibernate#466
-   UniqueConstraintSnapshotGenerator removed to avoid issue of index/constraint recreation by [@&#8203;MalloD12](https://github.com/MalloD12) in liquibase/liquibase-hibernate#468
-   Bump spring.version from 6.0.6 to 6.0.7 by [@&#8203;dependabot](https://github.com/dependabot) in liquibase/liquibase-hibernate#470
-   feat: Make test failing with unique constraints by [@&#8203;fleboulch](https://github.com/fleboulch) in liquibase/liquibase-hibernate#455
-   Bump jacoco-maven-plugin from 0.8.8 to 0.8.9 by [@&#8203;dependabot](https://github.com/dependabot) in liquibase/liquibase-hibernate#473
-   Bump maven-resources-plugin from 3.3.0 to 3.3.1 by [@&#8203;dependabot](https://github.com/dependabot) in liquibase/liquibase-hibernate#471
-   Bump maven-surefire-plugin from 2.22.2 to 3.0.0 by [@&#8203;dependabot](https://github.com/dependabot) in liquibase/liquibase-hibernate#469
-   Fix types handling by [@&#8203;filipelautert](https://github.com/filipelautert) in liquibase/liquibase-hibernate#467

#### New Contributors

-   [@&#8203;MalloD12](https://github.com/MalloD12) made their first contribution in liquibase/liquibase-hibernate#468
-   [@&#8203;fleboulch](https://github.com/fleboulch) made their first contribution in liquibase/liquibase-hibernate#455

**Full Changelog**: liquibase/liquibase-hibernate@v4.19.1...v4.21.0

</details>

<details>
<summary>liquibase/liquibase</summary>

### [`v4.21.1`](https://github.com/liquibase/liquibase/blob/HEAD/changelog.txt#Liquibase-4211-is-a-patch-release)

[Compare Source](liquibase/liquibase@v4.21.0...v4.21.1)

### [`v4.21.0`](https://github.com/liquibase/liquibase/blob/HEAD/changelog.txt#Liquibase-v4210-is-a-major-release)

[Compare Source](liquibase/liquibase@v4.20.0...v4.21.0)

</details>

<details>
<summary>vsch/flexmark-java</summary>

### [`v0.64.4`](vsch/flexmark-java@0.64.2...0.64.4)

[Compare Source](vsch/flexmark-java@0.64.2...0.64.4)

### [`v0.64.2`](vsch/flexmark-java@0.64.0...0.64.2)

[Compare Source](vsch/flexmark-java@0.64.0...0.64.2)

</details>

<details>
<summary>diffplug/spotless</summary>

### [`v2.36.0`](https://github.com/diffplug/spotless/blob/HEAD/CHANGES.md#&#8203;2360---2023-02-27)

##### Added

-   `gradlew equoIde` opens a repeatable clean Spotless dev environment. ([#&#8203;1523](diffplug/spotless#1523))
-   `cleanthat` added `includeDraft` option, to include draft mutators from composite mutators. ([#&#8203;1574](diffplug/spotless#1574))
-   `npm`-based formatters now support caching of `node_modules` directory ([#&#8203;1590](diffplug/spotless#1590))

##### Fixed

-   `JacksonJsonFormatterFunc` handles json files with an Array as root. ([#&#8203;1585](diffplug/spotless#1585))

##### Changes

-   Bump default `cleanthat` version to latest `2.1` -> `2.6` ([#&#8203;1569](diffplug/spotless#1569) and [#&#8203;1574](diffplug/spotless#1574))
-   Reduce logging-noise created by `npm`-based formatters ([#&#8203;1590](diffplug/spotless#1590) fixes [#&#8203;1582](diffplug/spotless#1582))

</details>

<details>
<summary>quarkusio/quarkus</summary>

### [`v2.16.7.Final`](https://github.com/quarkusio/quarkus/releases/tag/2.16.7.Final)

[Compare Source](quarkusio/quarkus@2.16.6.Final...2.16.7.Final)

##### Complete changelog

-   [#&#8203;33023](quarkusio/quarkus#33023) - Fix algorithm comparison bug in OIDC code loading the token decryption key
-   [#&#8203;33020](quarkusio/quarkus#33020) - Fixed example in command-mode-reference.adoc
-   [#&#8203;33012](quarkusio/quarkus#33012) - Update JReleaser guide for native executables
-   [#&#8203;32842](quarkusio/quarkus#32842) - Correct a typo in redis-reference.adoc
-   [#&#8203;32841](quarkusio/quarkus#32841) - Add a column before a table column separator `|`
-   [#&#8203;32838](quarkusio/quarkus#32838) - Fix a typo in security-openid-connect-multitenancy.adoc
-   [#&#8203;32771](quarkusio/quarkus#32771) - Prevent NPE for UserInfo String and Boolean properties
-   [#&#8203;32762](quarkusio/quarkus#32762) - Normalize paths for POM Model providers
-   [#&#8203;32753](quarkusio/quarkus#32753) - Update codestarts to use openjdk container images 1.15
-   [#&#8203;32751](quarkusio/quarkus#32751) - Codestarts - OpenJDK-Container Image not updated
-   [#&#8203;32740](quarkusio/quarkus#32740) - Add missing static import in config interceptor doc
-   [#&#8203;32738](quarkusio/quarkus#32738) - Fix guide oidc trust-store config parameter name
-   [#&#8203;32703](quarkusio/quarkus#32703) - Include MariaDB deprecated.properties
-   [#&#8203;32702](quarkusio/quarkus#32702) - Native MariaDb with useSsl throw NPE
-   [#&#8203;32692](quarkusio/quarkus#32692) - Allow ConfigMappings with default visibility
-   [#&#8203;32690](quarkusio/quarkus#32690) - Quarkus dev mode is not working with a certain type of folder tree due to dependency injection
-   [#&#8203;32679](quarkusio/quarkus#32679) - Logging with Panache: fix LocalVariablesSorter usage
-   [#&#8203;32669](quarkusio/quarkus#32669) - Replace remaining references to bcX-jdk150
-   [#&#8203;32663](quarkusio/quarkus#32663) - infov impacts local variable type
-   [#&#8203;32655](quarkusio/quarkus#32655) - Correct a minor error in native-reference.adoc
-   [#&#8203;32636](quarkusio/quarkus#32636) - Remove reference Uni::then in Mutiny primer
-   [#&#8203;32635](quarkusio/quarkus#32635) - Quarkus Mutiny guide mistake
-   [#&#8203;32603](quarkusio/quarkus#32603) - Avoid calling after construct callbacks twice when using `@Nested` tests
-   [#&#8203;32514](quarkusio/quarkus#32514) - Bump OWASP dependency check plugin version to 8.2.1
-   [#&#8203;32505](quarkusio/quarkus#32505) - Throw the exception if OIDC client fails to acquire the token
-   [#&#8203;32501](quarkusio/quarkus#32501) - Remove unnecessary line split from metadata yaml
-   [#&#8203;32500](quarkusio/quarkus#32500) - `YamlMetadataGenerator` emits yaml with line splits
-   [#&#8203;32481](quarkusio/quarkus#32481) - Fix NPE when OIDC TenantConfigResolver returns null
-   [#&#8203;32480](quarkusio/quarkus#32480) - RestClient with Oidc Token (OidcClientRequestReactiveFilter) is NOT failing when Token is wrong/unauthorized
-   [#&#8203;32449](quarkusio/quarkus#32449) - Multitenancy OIDC permit tenant enumeration
-   [#&#8203;32442](quarkusio/quarkus#32442) - Add one more CORS same origin unit test
-   [#&#8203;32419](quarkusio/quarkus#32419) - Correcting Resteasy Reactive docs
-   [#&#8203;32403](quarkusio/quarkus#32403) - Make SDKMAN releases minor for maintenance and preview releases
-   [#&#8203;32383](quarkusio/quarkus#32383) - Using `@InjectSpy` from a JUnit5 `@Nested` inner class leads to unreliable test result
-   [#&#8203;32360](quarkusio/quarkus#32360) - Qute validation - fix the way the namespace expressions are collected
-   [#&#8203;32355](quarkusio/quarkus#32355) - Cannot using 2 classes with Qute `@MessageBundle` with different namespace
-   [#&#8203;32349](quarkusio/quarkus#32349) - Better error on unparseable GraphQL JSON request
-   [#&#8203;31939](quarkusio/quarkus#31939) - A bit of javadoc for codegen
-   [#&#8203;31581](quarkusio/quarkus#31581) - Arc - Do not validate static members in inner non-static classes for CDI annotations
-   [#&#8203;31558](quarkusio/quarkus#31558) - JUnit `@Nested` Inner Classes with `@BeforeAll` and `@Transactional` annotations fail on initialization after upgrading to 2.16.3.Final
-   [#&#8203;31554](quarkusio/quarkus#31554) - RunTimeMappingsConfigBuilder failures (native build/tests) with 2.16.4

</details>

<details>
<summary>quarkusio/quarkus-platform</summary>

### [`v2.16.7.Final`](quarkusio/quarkus-platform@2.16.6.Final...2.16.7.Final)

[Compare Source](quarkusio/quarkus-platform@2.16.6.Final...2.16.7.Final)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

👻 **Immortal**: This MR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjQuMCJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants