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

domain - set some columns to arbitrary length (TEXT type) #304

Conversation

pmauduit
Copy link
Member

@pmauduit pmauduit commented Oct 23, 2024

In some cases we would need more than the default length for string (255chars), e.g. when using large logos or very long descriptions for our groups in the Console. Using a TEXT type sounds more appropriate than a VARCHAR which would require to raise the max number each time the limit is reached.

As indicated in a comment, this is not portable, but works with postgresql which is the de-facto standard in geOrchestra ? Rapidly checking, it looks like Oracle also supports it.

Tests: runtime tested.

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

geOrchestra/geonetwork checklist

  • PR only involves cherry-picked commits from upstream.
  • PR contains custom code which will soon be available in an upstream release and can be overriden => mention core-geonetwork version if possible.
  • PR contains custom geOrchestra code, which need to be verified during future migrations.

@pmauduit pmauduit requested a review from f-necas October 23, 2024 16:37
@f-necas
Copy link
Collaborator

f-necas commented Oct 24, 2024

The PR templates comes from core-geonetwork and not georchestra/geonetwork, weird ! (while writing this comment, I've seen that there's two PR templates. Can you remove the one in uppercase in this PR ?)

What about @lob annotation, could it be better and upstream-compliant ?

If it doesn't, is it possible to mention georchestra's specific features here :
https://github.com/georchestra/geonetwork/blob/georchestra-gn4.4.x/georchestra-migration/migration-dev-guide.md

I add the PR template to your description.

Anyway, it looks good to me if Lob doesn't work.

@pmauduit
Copy link
Member Author

pmauduit commented Nov 4, 2024

What about @lob annotation, could it be better and upstream-compliant ?

I think I tried this before using columnDefinition, and it was creating a column using a weird postgresql type, which made JPA fail afterwards.
I'll retry though because I'd like to have the details of what was going wrong.

@pmauduit
Copy link
Member Author

pmauduit commented Nov 4, 2024

Using @Lob annotation gives the following table layout (e.g. for groups):

georchestra=# \d geonetwork.groups 
                                 Table "geonetwork.groups"
           Column            |          Type          | Collation | Nullable |   Default   
-----------------------------+------------------------+-----------+----------+-------------
 id                          | integer                |           | not null | 
 description                 | oid                    |           |          | 
 email                       | character varying(128) |           |          | 
 enablecategoriesrestriction | character(1)           |           |          | 'n'::bpchar
 logo                        | oid                    |           |          | 
 name                        | character varying(255) |           | not null | 
 referrer                    | integer                |           |          | 
 website                     | character varying(255) |           |          | 
 defaultcategory_id          | integer                |           |          | 

Reading a bit about this oid postgresql datatype, it does not seem to be relevant for our usage. This issue looks pretty similar to what is described here: https://community.vahanacloud.com/t/lob-in-jpa-entity-creating-oid-column-in-postgres-how-can-i-store-them-as-text/1261/2 which actually suggests to use columnDefinition="TEXT" instead.

@f-necas
Copy link
Collaborator

f-necas commented Nov 4, 2024

Indeed. Let's go for text then. (With a bit of doc in geonetwork migration's files)

@pmauduit pmauduit force-pushed the domain-change-type-of-column-to-abritrary-long-text branch from 971b91b to 183f7d2 Compare November 19, 2024 17:09
@pmauduit
Copy link
Member Author

PR updated

@pmauduit
Copy link
Member Author

GHA is failing, but the same tests are in error when I run maven locally on the georchestra-gn4.4.x branch

In some cases we would need more than the default length for string
(255chars).

As indicated in a comment, this is not portable, but works with
postgresql which is the de-facto standard in geOrchestra ?
Rapidly checking, it looks like Oracle also supports it.

Tests: runtime tested.
@f-necas f-necas force-pushed the domain-change-type-of-column-to-abritrary-long-text branch from 7b70887 to 26215ec Compare November 20, 2024 14:00
@f-necas f-necas merged commit 345569d into georchestra-gn4.4.x Nov 20, 2024
2 checks passed
@pmauduit pmauduit deleted the domain-change-type-of-column-to-abritrary-long-text branch November 20, 2024 14:27
Copy link

💔 All backports failed

Status Branch Result
georchestra-gn4.2.x-24.0 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

backport --pr 304

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

f-necas added a commit that referenced this pull request Nov 20, 2024
…-to-abritrary-long-text

domain - set some columns to arbitrary length (TEXT type)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants