← Back to team overview

dhis2-devs team mailing list archive

Re: Limit characters in Comment

 

Hi, 
in MySQL and 2.15 the type seems to be longtext (see below).

In any case, the patch suggested below is to 1) manually change the column type 2) change the history.vm and history.js. Is that supposed to enough, or are further changes required?

Olav



+------------------------+--------------+------+-----+---------+-------+
| Field                  | Type         | Null | Key | Default | Extra |
+------------------------+--------------+------+-----+---------+-------+
| dataelementid          | int(11)      | NO   | PRI | NULL    |       |
| periodid               | int(11)      | NO   | PRI | NULL    |       |
| sourceid               | int(11)      | NO   | PRI | NULL    |       |
| categoryoptioncomboid  | int(11)      | NO   | PRI | NULL    |       |
| attributeoptioncomboid | int(11)      | NO   | PRI | NULL    |       |
| value                  | varchar(255) | YES  |     | NULL    |       |
| storedby               | varchar(100) | YES  |     | NULL    |       |
| lastupdated            | datetime     | YES  |     | NULL    |       |
| comment                | longtext     | YES  |     | NULL    |       |
| followup               | tinyint(1)   | YES  |     | NULL    |       |
+------------------------+--------------+------+-----+---------+-------+




10. sep. 2014 kl. 15:19 skrev Lars Helge Øverland <larshelge@xxxxxxxxx>:

> Hi Olav,
> 
> the datavalue.value column is of type varchar and not text. This might be unfortunate but there is an overhead in using text vs varchar. The long text vs text is more a UI setting to indicate whether to display an input field or text area. 
> 
> I am not sure how huge the difference is between text and varchar these days so it could be looked into whether changing is feasible. I have seen the requirement for storing "narratives" as data a few places.
> 
> regards,
> 
> Lars
> 
> 
> On Wed, Sep 10, 2014 at 8:52 AM, Olav Poppe <olav.poppe@xxxxxx> wrote:
> Hi,
> I’m trying to apply the below patch to allow comments longer than 360 characters. Changing the .js and .vm file works fine and the text field allows long comments, BUT the system still refuses to store the data values with long comments - 409 conflict is returned from the server. The comment column has type «longtext». Any ideas of what could be the problem?
> 
> Searching through the source code, I found two additional files where the lengt of the comments are mentioned:
> - validationUtils.java, function commentIsValid() checks for comment length
> - DataValue.hbm.xml has "<property name=«comment» length="360" />"
> 
> Do these also need to be changed? If so, I guess a custom .war file will be needed (as opposed to just changing the .vm and .js files)?
> 
> Olav
> 
> 
> 
> 9. apr. 2014 kl. 11:48 skrev channara rin <rin.channara@xxxxxxxxx>:
> 
>> Oh!, i am using MySQL. where i can find this sql expression?
>> 
>> 
>> On Wed, Apr 9, 2014 at 4:46 PM, Jason Pickering <jason.p.pickering@xxxxxxxxx> wrote:
>> Could be. On postgres, the datavalue table (at least on my system) looks like this
>> 
>> CREATE TABLE datavalue
>> (
>>   dataelementid integer NOT NULL,
>>   periodid integer NOT NULL,
>>   sourceid integer NOT NULL,
>>   categoryoptioncomboid integer NOT NULL,
>>   value character varying(255),
>>   storedby character varying(100),
>>   lastupdated timestamp without time zone,
>>   comment character varying(360),
>>   followup boolean,
>> ....
>> 
>> In that case, not sure then. :-/
>> 
>> Regards,
>> Jason
>> 
>> 
>> 
>> On Wed, Apr 9, 2014 at 11:42 AM, channara rin <rin.channara@xxxxxxxxx> wrote:
>> The default, comment field in datavalue table is longtext type.
>> 
>> Best Regards,
>> CHANNARA
>> 
>> 
>> On Wed, Apr 9, 2014 at 4:40 PM, Jason Pickering <jason.p.pickering@xxxxxxxxx> wrote:
>> Did you change the database field type from varchar to text?
>> 
>> Regards,
>> Jason
>> 
>> 
>> 
>> On Wed, Apr 9, 2014 at 11:31 AM, channara rin <rin.channara@xxxxxxxxx> wrote:
>> Dear Lars,
>> I tried to change in history.js
>> but when i enter longer than 360 in comment, and press "Save Comment". It always jump:
>> CONSOLE
>> -------------------------------------
>> ReferenceError: i18n_saving_comment_failed_error_code is not defined                          history.js:64
>> -------------------------------------
>> 
>> history.js
>> --------------------------------------
>> function handleError( xhr, textStatus, errorThrown )
>>     {
>>         markComment( COLOR_RED );
>>         window.alert( i18n_saving_comment_failed_error_code + '\n\n' + xhr.responseText );
>>     }
>> 
>> 
>> On Wed, Apr 9, 2014 at 3:29 PM, Lars Helge Øverland <larshelge@xxxxxxxxx> wrote:
>> The cell border will be green for fields which have comments (next time you open that form).
>> 
>> 
>> 
>> 
>> On Wed, Apr 9, 2014 at 10:27 AM, channara rin <rin.channara@xxxxxxxxx> wrote:
>> Great, Thank you.
>> SO i need to modify the 360 in history.js file?
>> 
>> AND another problem is. when has comment, can show highlight data value in dataset that has text in that comment? SO it is easy for us(M&E staff) to view if that data value has comment..
>> 
>> Thank you
>> CHANNARA
>> 
>> 
>> 
>> 
>> 
>> On Wed, Apr 9, 2014 at 3:02 PM, Lars Helge Øverland <larshelge@xxxxxxxxx> wrote:
>> Hi Channara,
>> 
>> the max is actually 255 characters, backed by a "varchar" column in the database. I'm sorry but we don't plan to change it to a "text" type column anytime soon - reason is just that most comments are pretty short and "text" requires more storage space on disk.
>> 
>> Now that said you are of course free to change the column type to text directly in your database, and then apply the patch copied below this email to remove the validation.
>> 
>> regards,
>> 
>> Lars
>> 
>> -----
>> 
>> 
>> === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js'
>> --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2014-02-27 04:15:35 +0000
>> +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js	2014-04-09 08:01:57 +0000
>> @@ -5,14 +5,6 @@
>>  	
>>      var commentValue = $( '#commentTextArea' ).val();
>>  
>> -    if ( commentValue.length > 360 )
>> -    {
>> -        markComment( COLOR_YELLOW );
>> -        window.alert(i18n_value_too_long + " for comment field");
>> -
>> -        return;
>> -    }
>> -
>>      var commentSaver = new CommentSaver( currentDataElementId, currentOptionComboId, commentValue );
>>  
>>      commentSaver.save();
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> On Wed, Apr 9, 2014 at 6:55 AM, channara rin <rin.channara@xxxxxxxxx> wrote:
>> Dear All,
>> I found that, in the Comment in data value in dataset is limit character around 360characters. 
>> Can we extend to unlimited characters for comments?
>> 
>> 
>> Thank you
>> CHANNARA
>> 
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help   : https://help.launchpad.net/ListHelp
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help   : https://help.launchpad.net/ListHelp
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help   : https://help.launchpad.net/ListHelp
> 
> 


References