utplsql 高级数据比较中的点表示法

dot notation in utplsql advanced data comparison

我在 utPLSQL 网站上看到了下面的代码片段。

procedure test_cur_skip_columns_eq is
  l_expected sys_refcursor;
  l_actual   sys_refcursor;
begin
  open l_expected for select 'text' ignore_me, d.* from user_tables d;
  open l_actual   for select sysdate "ADate",  d.* from user_tables d;
  ut.expect( l_actual ).to_equal( l_expected ).exclude( 'IGNORE_ME,ADate' );
end;

procedure test_cur_skip_columns_cn is
  l_expected sys_refcursor;
  l_actual   sys_refcursor;
begin
  open l_expected for select 'text' ignore_me, d.* from user_tables d where rownum = 1;
  open l_actual   for select sysdate "ADate",  d.* from user_tables d;
  ut.expect( l_actual ).to_contain( l_expected ).exclude( 'IGNORE_ME,ADate' );
end;

它有这行带点符号的代码,ut.expect( l_actual ).to_contain( l_expected ).exclude( 'IGNORE_ME,ADate' );。我阅读了一些关于点符号用法的 oracle 文档,到处都是 package_name.object_name 或 schema_name.table_name。但是上面提到的代码行看起来不像这些。我很想知道每个点之间的那些对象是什么。感谢任何帮助。

I am interested to know what are those objects between each dots.

这些确实是 oracle objects (aka user-defined types, aka abstract data types)。

ut.expect( l_actual ).to_contain( l_expected ).exclude( 'IGNORE_ME,ADate' );

这里发生了什么:

  • ut contains a function named expect 包 return 是 ut_expectation_compound 类型的对象;
  • ut_expectation_compound is a type that defines two member functions: to_contain and exclude。它们都 return ut_expectation_compound 允许像这样链接方法调用。

您可能想阅读 Object-Relational Developer's Guide to get an introduction into the topic. Also read PLSQL Language Reference - 它应该为您关于 PLSQL 语法的大部分问题提供答案。