Skip to content

Commit 972bd97

Browse files
yahondaclaude
andcommitted
Add test for TABLE OF %ROWTYPE parameter in package
Reproduces the issue reported in #200 where ensure_tmp_tables_created generates invalid DDL containing %ROWTYPE literally. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 412d59e commit 972bd97

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

spec/plsql/procedure_spec.rb

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,6 @@ def new_candidate(status)
15081508
before(:all) do
15091509
# get actual database_version
15101510
plsql.connect! CONNECTION_PARAMS
1511-
skip "Skip if the actual database version is 18c or higher" if (plsql.connection.database_version <=> [18, 0, 0, 0]) >= 0
15121511
end
15131512

15141513
before do
@@ -2426,3 +2425,37 @@ def new_candidate(status)
24262425
expect(field_names.none? { |name| name.to_s.start_with?("sys_nc") }).to be true
24272426
end
24282427
end
2428+
2429+
describe "Function with TABLE OF %ROWTYPE parameter defined in package" do
2430+
before(:all) do
2431+
plsql.connect! CONNECTION_PARAMS
2432+
plsql.execute "DROP PACKAGE test_rowtype_pkg" rescue nil
2433+
plsql.execute "DROP TABLE test_rowtype_tbl" rescue nil
2434+
plsql.execute "CREATE TABLE test_rowtype_tbl (id NUMBER, name VARCHAR2(50))"
2435+
plsql.execute <<-SQL
2436+
CREATE OR REPLACE PACKAGE test_rowtype_pkg IS
2437+
TYPE t_tab IS TABLE OF test_rowtype_tbl%ROWTYPE;
2438+
FUNCTION test_fn(p_tab IN t_tab) RETURN NUMBER;
2439+
END;
2440+
SQL
2441+
plsql.execute <<-SQL
2442+
CREATE OR REPLACE PACKAGE BODY test_rowtype_pkg IS
2443+
FUNCTION test_fn(p_tab IN t_tab) RETURN NUMBER IS
2444+
BEGIN
2445+
RETURN p_tab.COUNT;
2446+
END;
2447+
END;
2448+
SQL
2449+
end
2450+
2451+
after(:all) do
2452+
plsql.execute "DROP PACKAGE test_rowtype_pkg" rescue nil
2453+
plsql.execute "DROP TABLE test_rowtype_tbl" rescue nil
2454+
plsql.logoff
2455+
end
2456+
2457+
it "should execute function with TABLE OF %ROWTYPE parameter" do
2458+
result = plsql.test_rowtype_pkg.test_fn([{ id: 1, name: "test" }])
2459+
expect(result).to eq(1)
2460+
end
2461+
end

0 commit comments

Comments
 (0)