Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Exception when comparing collections with utp.ut.expect #1235

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

Closed
SElfimov opened this issue Sep 28, 2022 · 6 comments · Fixed by #1238
Closed

Exception when comparing collections with utp.ut.expect #1235

SElfimov opened this issue Sep 28, 2022 · 6 comments · Fixed by #1238
Assignees
Labels
Milestone

Comments

@SElfimov
Copy link

SElfimov commented Sep 28, 2022

Describe the bug
When comparing collections converted to anydata with utp.ut.expect sometimes we get this error, usually it works correctly.

Provide version info
utPLSQL 3.1.12

Information about client software
not applicable

To Reproduce

Run the below script

-- type creation
/*
create or replace type tp_r_ug_sportsman_invitation_result is object
(
    code              number(18),
    sportsman_name    varchar2(100),
    mobile_phone      varchar2(20),
    err_code          number,
    err_text          varchar2(4000)
);
create or replace type tp_t_ug_sportsman_invitation_result is table of tp_r_ug_sportsman_invitation_result;
*/

declare
    --records to compare
    --record 1
    v_sportsman_invitation_result  tp_t_ug_sportsman_invitation_result := tp_t_ug_sportsman_invitation_result
    (
        tp_r_ug_sportsman_invitation_result
        (
            code            => 1,
            sportsman_name  => 'sportsman_1',
            mobile_phone    => '79666666666',
            err_code        => 1,
            err_text        => null
        )
    );

    --record 2
    v_sportsman_invitation_exp  tp_t_ug_sportsman_invitation_result := tp_t_ug_sportsman_invitation_result
    (
        tp_r_ug_sportsman_invitation_result
        (
            code            => 1,
            sportsman_name  => 'sportsman_1',
            mobile_phone    => '79666666666',
            err_code        => 1,
            err_text        => null
        )
    );
begin
    --check rows in collections
    utp.ut.expect(v_sportsman_invitation_result.count, 'count collection')
          .to_equal(v_sportsman_invitation_exp.count);

    if v_sportsman_invitation_result.count = v_sportsman_invitation_exp.count then

        for i in 1..v_sportsman_invitation_result.count
        loop
            --check values of each part of a record
            utp.ut.expect(v_sportsman_invitation_result(i).sportsman_name, 'sportsman_name(' || i || ')')
                .to_equal(v_sportsman_invitation_exp(i).sportsman_name);
            utp.ut.expect(v_sportsman_invitation_result(i).mobile_phone, 'mobile_phone(' || i || ')')
                .to_equal(v_sportsman_invitation_exp(i).mobile_phone);
            utp.ut.expect(v_sportsman_invitation_result(i).err_code, 'err_code(' || i || ')')
                .to_equal(v_sportsman_invitation_exp(i).err_code);
        end loop;

        --compare 2 collections, here we get the exception
	utp.ut.expect(anydata.convertCollection(v_sportsman_invitation_result), 'Collections equal')
              .to_equal(anydata.convertCollection(v_sportsman_invitation_exp));

    end if;
end;

See the exception:

ORA-06502: PL/SQL: : numeric or value error: character string buffer too small
ORA-06512: на "UTP.UT_DATA_VALUE_ANYDATA", line 98
ORA-06512: на "SYS.DBMS_SQL", line 2146
ORA-06512: на "UTP.UT_CURSOR_DETAILS", line 100
ORA-06512: на "UTP.UT_DATA_VALUE_ANYDATA", line 84
ORA-06512: на "UTP.UT_DATA_VALUE_ANYDATA", line 114
ORA-06512: на "UTP.UT", line 33
ORA-06512: на line 61

Expected behavior

We expect to get collections differences.

@jgebal jgebal transferred this issue from utPLSQL/utPLSQL-cli Sep 28, 2022
@jgebal
Copy link
Member

jgebal commented Sep 28, 2022

Please provide information about your database version and type (SE/EE/XE/Exadata/Cloud/on-prem)

@SElfimov
Copy link
Author

Hello
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.13.0.0.0, EE exadata

@jgebal jgebal added the bug label Sep 29, 2022
@jgebal jgebal self-assigned this Sep 29, 2022
@jgebal
Copy link
Member

jgebal commented Sep 29, 2022

The problem relates to the datatype we use in DBMS_SQL to describe cursor data.
Since you're using long object names (over 30 characters) that were not supported in older versions of oracle DB you code fails.

On our side, we need to make a fix with dynamic compilation.
So we would continue to use DBMS_SQL.DESC_REC3 on DB versions 11, 12.1 but would then use DBMS_SQL.DESC_REC4 for DB version 12.2 and above.

That should not b a massive change but it will be provided in some next version of utPLSQL.

Until then, the short-term solution would be to use object/collection type names that are shorter than 30 characters.

@jgebal jgebal added this to the 3.1.13 milestone Sep 29, 2022
@SElfimov
Copy link
Author

jgebal, thank you for your answer and recomendation.

@SElfimov SElfimov reopened this Sep 29, 2022
@SElfimov
Copy link
Author

jgebal, should I close the issue or you will close it after the fix ?

@jgebal
Copy link
Member

jgebal commented Sep 29, 2022

I will close it after a fix.
Thank you for reporting it and providing very good example that allowed for identification of the root cause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants