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

Skip to content

Add support for empty BLOB/CLOB #707

Closed
@jgebal

Description

@jgebal

Currently BLOB/CLOB when empty (initialized but not assigned a value) behaves like this:

create or replace package test_empty_blob_clob is
  --%suite(Empty BLOB/CLOB behavior)

  --%test(Empty BLOB fails on is_null)
  procedure empty_blob_is_null;

  --%test(Empty CLOB fails on is_null)
  procedure empty_clob_is_null;

  --%test(Empty BLOB succeeds on is_not_null)
  procedure empty_blob_is_not_null;

  --%test(Empty CLOB succeeds on is_not_null)
  procedure empty_clob_is_not_null;

  --%test(Empty BLOB fails on is_empty)
  procedure empty_blob_is_empty;

  --%test(Empty CLOB fails is_empty)
  procedure empty_clob_is_empty;

  --%test(Empty BLOB succeeds on empty BLOB comparison)
  procedure empty_blob_equals_empty;

  --%test(Empty CLOB succeeds on empty CLOB comparison)
  procedure empty_clob_equals_empty;
  
end;
/
create or replace package body test_empty_blob_clob is

  procedure empty_blob_is_null is
    l_lob blob := empty_blob();
  begin
    ut.expect(l_lob).to_be_null;
  end;

  procedure empty_clob_is_null is
    l_lob clob := empty_clob();
  begin
    ut.expect(l_lob).to_be_null;
  end;

  procedure empty_blob_is_not_null is
    l_lob blob := empty_blob();
  begin
    ut.expect(l_lob).to_be_not_null;
  end;

  procedure empty_clob_is_not_null is
    l_lob clob := empty_clob();
  begin
    ut.expect(l_lob).to_be_not_null;
  end;

  procedure empty_blob_is_empty is
    l_lob blob := empty_blob();
  begin
    ut.expect(l_lob).to_(be_empty);
  end;

  procedure empty_clob_is_empty is
    l_lob clob := empty_clob();
  begin
    ut.expect(l_lob).to_(be_empty);
  end;

  procedure empty_blob_equals_empty is
    l_lob blob := empty_blob();
  begin
    ut.expect(l_lob).to_equal(empty_blob());
  end;


  procedure empty_clob_equals_empty is
    l_lob clob := empty_clob();
  begin
    ut.expect(l_lob).to_equal(empty_clob());
  end;
  
end;
/

Outcomes:

Empty BLOB/CLOB behavior
  Empty BLOB fails on is_null [.107 sec] (FAILED - 1)
  Empty CLOB fails on is_null [.007 sec] (FAILED - 2)
  Empty BLOB succeeds on is_not_null [.006 sec]
  Empty CLOB succeeds on is_not_null [.003 sec]
  Empty BLOB fails on is_empty [.01 sec] (FAILED - 3)
  Empty CLOB fails is_empty [.004 sec] (FAILED - 4)
  Empty BLOB succeeds on empty BLOB comparison [.009 sec]
  Empty CLOB succeeds on empty CLOB comparison [.003 sec]
 
Failures:
 
  1) empty_blob_is_null
      Actual: NULL (blob) was expected to be null
      at "UT3.TEST_EMPTY_BLOB_CLOB.EMPTY_BLOB_IS_NULL", line 6 ut.expect(l_lob).to_be_null;
      
       
  2) empty_clob_is_null
      Actual: NULL (clob) was expected to be null
      at "UT3.TEST_EMPTY_BLOB_CLOB.EMPTY_CLOB_IS_NULL", line 12 ut.expect(l_lob).to_be_null;
      
       
  3) empty_blob_is_empty
      The matcher 'be empty' cannot be used with data type (blob).
      at "UT3.TEST_EMPTY_BLOB_CLOB.EMPTY_BLOB_IS_EMPTY", line 30 ut.expect(l_lob).to_(be_empty);
      
       
  4) empty_clob_is_empty
      The matcher 'be empty' cannot be used with data type (clob).
      at "UT3.TEST_EMPTY_BLOB_CLOB.EMPTY_CLOB_IS_EMPTY", line 36 ut.expect(l_lob).to_(be_empty);
      
       
Finished in .163359 seconds
8 tests, 4 failed, 0 errored, 0 disabled, 0 warning(s)

I would expect the tests to pass:

  Empty BLOB fails on is_empty [.01 sec] (FAILED - 3)
  Empty CLOB fails is_empty [.004 sec] (FAILED - 4)

I would also expect the expectation failure message to say:

      Actual: EMPTY (blob) was expected to be null

Rather than:

      Actual: NULL (blob) was expected to be null

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions