Project

General

Profile

Feature #9440

get-codepage() function should work with CLOB fields

Added by Greg Shah over 1 year ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
production:
No
env_name:
topics:

History

#1 Updated by Greg Shah over 1 year ago

The current implementation of GET-CODEPAGE() (implemented in #3753) works with LONGCHAR but not with CLOB fields. It is supposed to work with both. As implemented, it is hard coded to call longchar.getCodePage() which is not OK. In this task, the work is to:

  • make a generic method in I18NOps and accept both LONGCHAR (get-codepage(lc-var)) and CLOB (get-codepage(buffer-handle:buffer-value))
  • redirect to the existing longchar.getCodePage() if the parameter is LONGCHAR
  • add support for CLOB and call it if the parameter is a CLOB field

#2 Updated by Constantin Asofiei about 1 year ago

  • Assignee set to Teodor Gorghe

#3 Updated by Teodor Gorghe about 1 year ago

  • Status changed from New to WIP
  • % Done changed from 0 to 80
  • reviewer Constantin Asofiei added

Commited revision 15909 on branch 9440a.
- Implemented a new method on I18nOps getCodePage(BaseDataType).
- Changed the conversion on builtin_functions.rules to use I18nOps.getCodePage(BaseDataType), instead of longchar.getCodePage(BaseDataType).

I'm currently writing some test cases, to test the implementation.

#4 Updated by Teodor Gorghe about 1 year ago

I did managed to get the testcases project setup done. Right now, TestGetCodepage.cls fails because the code page is hard-coded and it does not match with the default SESSION:CPINTERNAL (1252) code page. I will add some new checks on that test, on the next working day.

#5 Updated by Teodor Gorghe about 1 year ago

  • Status changed from WIP to Review

#6 Updated by Constantin Asofiei about 1 year ago

  • Status changed from Review to WIP
Teodor, review of 9440a rev 15909:
  • builtin_functions.rules - this code:
             <rule>ftype == prog.kw_get_codp
                <action>methodText = "I18nOps.getCodePage"</action>
                <action>methodType = java.static_method_call</action>
             </rule>
    

    should emit longchar.getcodePage, clob.getCodePage and I18nOps.getCodePage depending on the type of the argument. See ExpressionConversionWorker.expressionType(Aast) (and its usage like ecw.expressionType(...) throughout TRPL) and use this to emit different calls for different arguments
  • I18nOps.java
    • please double-check your editor - there are lots of unintended white-space changes. Revert the file (bzr revert -r <trunk-rev> <file>) and use bzr diff -r <trunk-rev> --using meld <file> to see the actual differences in the file before committing
    • should getCodePage raise an ERROR condition if the argument is not a clob or longchar?
  • you need to change longchar.getCodePage to treat only longchar cases
  • remove longchar.getCodePage(BDT), as this will only be in I18Ops
  • add clob.getCodePage(clob)
  • when adding history entry to a file, make sure the copyright year (right-side) is updated, like 2005-2025 for builtin_functions.rules

#7 Updated by Teodor Gorghe about 1 year ago

Commited revision 15910 on branch 9440a, with the changes according to the latest code review.

#8 Updated by Teodor Gorghe about 1 year ago

  • Status changed from WIP to Review

#9 Updated by Constantin Asofiei about 1 year ago

Review of 15910 rev 9440a:
  • this must nest the @rule@s (like if/then/(if/then/else)/else); currently is is (if/then)(if/then/else).
                <rule>cls == "longchar" 
                   <action>methodText = "longchar.getCodePage"</action>
                </rule>
                <rule>cls == "clob" 
                   <action>methodText = "clob.getCodePage"</action>
                   <action on="false">methodText = "I18nOps.getCodePage"</action>
                </rule>
    

    correct:
                <rule>cls == "longchar" 
                   <action>methodText = "longchar.getCodePage"</action>
                   <rule on="false">cls == "clob" 
                      <action>methodText = "clob.getCodePage"</action>
                      <action on="false">methodText = "I18nOps.getCodePage"</action>
                   </rule>
                </rule>
    
  • otherwise, the code looks good; but, please use character.UNKNOWN instead of new character(); also, look into the 9060b branch, and if longchar and clob are not changed to use character.UNKNOWN or character.of or character.EMPTY_STRING instead of new character, please make these improvements in this branch.

#10 Updated by Teodor Gorghe about 1 year ago

Commited revision 15911 on branch 9440a.
I changed the builtin_functions.rules, with the changes you provided. In longchar and clob classes, there are no usages of new character(). I changed new character() call from I18nOps.getCodepage(BDT) to use character.UNKNOWN.

#11 Updated by Teodor Gorghe about 1 year ago

Commited revision 15912 on branch 9440a.
Replaced new character() with character.UNKNOWN on longchar.getCodePage().

#12 Updated by Constantin Asofiei about 1 year ago

I'm OK with the changes in rev 15912.

What standalone tests did you use for this?

#13 Updated by Teodor Gorghe about 1 year ago

I modified the /tests/base_language/builtin_functions/functionality/TestGetCodepage.cls to use SESSION:CPINTERNAL, instead of "ISO8859-1". Do I need to commit that test?

#14 Updated by Constantin Asofiei about 1 year ago

Please expand the test to also use get-codepage(buffer ttTable::fClob) (i.e. the POLY case which should convert to I18NOps.getCodePage). And a case with get-codepage(buffer ttTable::fInt) which would throw the error. Please run the test in both FWD and OE.

#15 Updated by Teodor Gorghe about 1 year ago

When using get-codepage(buffer ttTable::fInt), on OpenEdge, it does not throw any error. The returned value is ?.
Do I need to change the I18nOps.getCodePage(BDT) to not throw error when using other types of instances?

#16 Updated by Constantin Asofiei about 1 year ago

Teodor Gorghe wrote:

When using get-codepage(buffer ttTable::fInt), on OpenEdge, it does not throw any error. The returned value is ?.
Do I need to change the I18nOps.getCodePage(BDT) to not throw error when using other types of instances?

Yes, if 4GL shows that it returns something only for clob or longchar args, and unknown for any other type, then FWD must do the same.

#17 Updated by Teodor Gorghe about 1 year ago

  • % Done changed from 80 to 100

Commited revision 1758 on testcases.
Commited revision 15913 on P2J branch 9440a.

#18 Updated by Constantin Asofiei about 1 year ago

  • Status changed from Review to Internal Test

I'm OK with the changes.

#19 Updated by Teodor Gorghe about 1 year ago

Ok, thanks.
Related to this task, I noticed that the task status become "Internal Test".
What tests do I need to run?

#20 Updated by Constantin Asofiei about 1 year ago

Teodor Gorghe wrote:

Ok, thanks.
Related to this task, I noticed that the task status become "Internal Test".
What tests do I need to run?

Run conversion for a simple app which has get-codepage.

#21 Updated by Constantin Asofiei about 1 year ago

  • Status changed from Internal Test to Merge Pending

Please rebase and merge 9440a now.

#22 Updated by Teodor Gorghe about 1 year ago

  • Status changed from Merge Pending to Test

Branch 9440a was merged to trunk rev 15975 and archived.

#23 Updated by Constantin Asofiei 10 months ago

  • Status changed from Test to Closed

Also available in: Atom PDF