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

File attribute, character limit when adding via Admin pages #2066

Closed
tuli opened this issue Oct 22, 2024 · 6 comments
Closed

File attribute, character limit when adding via Admin pages #2066

tuli opened this issue Oct 22, 2024 · 6 comments

Comments

@tuli
Copy link

tuli commented Oct 22, 2024

User story

As a curator
I want to associate sample value to a dataset file
So that the the sample used or refered to by the file is linked

Acceptance tests

 Scenario: Can add very long sample value
    Given I have signed in as admin
    And I am on "/adminFile/update/id/13973"
    And I press the button "Show New Attribute Fields"
    When I select "Example data" in menu "FileAttributes_new_attribute_id"
    And I fill in the text input "FileAttributes[new][value]" with "embryophyta_odb10 C:99.1%[S:77.9%,D:21.2%],F:0.4%,M:0.5%,n:1614"
    And I press the button "Add attribute"
    Then I should see a file attribute table
      | Attribute Name | Value     | Unit |
      | last_modified  | 2013-7-15 |      |
      | Example data            | embryophyta_odb10 C:99.1%[S:77.9%,D:21.2%],F:0.4%,M:0.5%,n:1614       |      |
 Scenario: Can edit in a very long sample value
    Given I have signed in as admin
    And I am on "/adminFile/update/id/13973"
    And I press the button "Edit"
    And I fill in the text input "FileAttributes[edit][value]" with "Monday 15th July 2013, 00:00:00 AM Europe/Paris, 3463456435745634256234623456234562 bytes changed, version 235235.3423523"
    And I press the button "Save Attribute"
    Then I should see a file attribute table
      | Attribute Name | Value     | Unit |
      | last_modified  | Monday 15th July 2013, 00:00:00 AM Europe/Paris, 3463456435745634256234623456234562 bytes changed, version 235235.3423523 |      |
Scenario: I can expand the Value field for large input
Given I navigate to "/adminFile/update/id/13973"
When I want to add a large value of sample
Then I can expand the value field so I can see my whole entry 

Additional infos

Describe the bug
There is a character limit on File Attributes when added via the File Admin page.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://gigadb.org/adminFile/update/id/546450
  2. Scroll down to Attributes
  3. Note that "embryophyta_odb10 C99.1%[S" was truncated during spreadsheet upload (a different issue).
  4. Click Edit
  5. Attempt to add "embryophyta_odb10 C:99.1%[S:77.9%,D:21.2%],F:0.4%,M:0.5%,n:1614"
  6. Note that only "embryophyta_odb10 C:99.1%[S:77.9%,D:21.2%],F:0.4%," is allowed.

Expected behavior
When I paste "embryophyta_odb10 C:99.1%[S:77.9%,D:21.2%],F:0.4%,M:0.5%,n:1614" I want the whole value to be pasted in.

Screenshots
Screenshot 2024-10-22 at 14 28 54

Desktop (please complete the following information):
iOS Venture 13.4
Browser Safari
Version 16.5

Additional context
This is for a dataset that I am making public. I can still do so w/o these values (I can add them later), but it's something that I'd like fixed soon please.

@rija
Copy link
Contributor

rija commented Oct 24, 2024

Hi @luistoptal,

After checking the database schema (which allow long sample values), the issue seems to be only an HTML issue (max 50 limit in HTML).

This issue would benefit from a new test scenarios being added to tests/acceptance/AdminFileAttributes.feature.
See the "Acceptance tests" section in the description of this issue for example scenarios.

@luistoptal
Copy link
Collaborator

@rija in sql/gigadb_tables.sql I see

CREATE TABLE file_attributes (
    id integer NOT NULL,
    file_id integer NOT NULL,
    attribute_id integer NOT NULL,
    value character varying(50),
    unit_id character varying(30)
);

wouldn't that mean that teh max value length is set to 50 also from the DB schema?

@rija
Copy link
Contributor

rija commented Nov 12, 2024

@rija in sql/gigadb_tables.sql I see

CREATE TABLE file_attributes (
    id integer NOT NULL,
    file_id integer NOT NULL,
    attribute_id integer NOT NULL,
    value character varying(50),
    unit_id character varying(30)
);

wouldn't that mean that teh max value length is set to 50 also from the DB schema?

Hi @luistoptal,
that file doesn't represent the state of the database schema (it should probably be deleted)
the schema being used is obtained from running database migrations.
See: https://www.yiiframework.com/doc/guide/1.1/en/database.migration
to verify what is the current database schema obtained after running the database migrations,
you will have to connect to the database server with a postgresql client (e.g: psql command or GUI apps like DBeaver or Pgadmin):

$ psql -h localhost -p 54321 -U gigadb -d gigadb -c "\d file_attributes"
Password for user gigadb:
                                       Table "public.file_attributes"
    Column    |          Type           | Collation | Nullable |                   Default
--------------+-------------------------+-----------+----------+---------------------------------------------
 id           | integer                 |           | not null | nextval('file_attributes_id_seq'::regclass)
 file_id      | integer                 |           | not null |
 attribute_id | integer                 |           | not null |
 value        | character varying(1000) |           |          |
 unit_id      | character varying(30)   |           |          |
Indexes:
    "file_attributes_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "file_attributes_attribute_id_fkey" FOREIGN KEY (attribute_id) REFERENCES attribute(id)
    "file_attributes_file_id_fkey" FOREIGN KEY (file_id) REFERENCES file(id) ON DELETE CASCADE
    "file_attributes_unit_id_fkey" FOREIGN KEY (unit_id) REFERENCES unit(id)

if you do that, you will see that the max value is actually 1000, not 50, nor 150.

@rija
Copy link
Contributor

rija commented Nov 12, 2024

Hi @luistoptal,
also for this issue:

rija added a commit that referenced this issue Nov 12, 2024
)

max length for attribute value set to 1000 in the view and models

Refs:  #2066
@rija
Copy link
Contributor

rija commented Nov 12, 2024

Hi @luistoptal,
However, the PR #2069 doesn't implement the third acceptance scenario.
That is still to be done.

I suggest you rebase your PR onto develop to get the main fix, and focus your PR on implementing the third scenario?

@luistoptal
Copy link
Collaborator

@rija I updated my PR with the suggested changes

rija added a commit that referenced this issue Nov 27, 2024
…for long values(Merge pull request #2081)

Extend max length for file attribute values to 150
merged with fix-2066: max length for attribute value set to 1000 #2069 (by merging develop branch) so new max length is 1000
create column layout for new attr form
added partial that takes care of expanding / collapsing long descriptions protected/views/shared/_longTextToggler.php, it can be reused in other similar cases

Refs:  #2066
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

6 participants