Skip to content

Commit e4a6641

Browse files
yahondaclaude
andcommitted
Remap TIMESTAMP(n) WITH LOCAL TIME ZONE to standard form
ALL_TAB_COLUMNS returns TIMESTAMP(6) WITH LOCAL TIME ZONE for columns declared as TIMESTAMP WITH LOCAL TIME ZONE. Remap to the standard form in get_field_definitions so that procedure metadata and temp table DDL use the correct type name. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3a7a307 commit e4a6641

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

lib/plsql/procedure.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ def get_field_definitions(argument_metadata) # :nodoc:
397397

398398
col_no, col_name, col_type_name, col_length, col_precision, col_scale, col_char_length, col_char_used = r
399399

400+
if col_type_name =~ /\ATIMESTAMP\(\d+\) WITH LOCAL TIME ZONE\z/
401+
col_type_name = "TIMESTAMP WITH LOCAL TIME ZONE"
402+
end
403+
400404
fields[col_name.downcase.to_sym] = {
401405
position: col_no.to_i,
402406
data_type: col_type_name,

spec/plsql/procedure_spec.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,35 @@ def new_candidate(status)
24272427
end
24282428
end
24292429

2430+
describe "Function with TIMESTAMP WITH LOCAL TIME ZONE column in %ROWTYPE" do
2431+
before(:all) do
2432+
plsql.connect! CONNECTION_PARAMS
2433+
plsql.execute "DROP FUNCTION test_timestamp_ltz_fn" rescue nil
2434+
plsql.execute "DROP TABLE test_timestamp_ltz" rescue nil
2435+
plsql.execute "CREATE TABLE test_timestamp_ltz (id NUMBER, ts TIMESTAMP WITH LOCAL TIME ZONE)"
2436+
plsql.execute <<-SQL
2437+
CREATE OR REPLACE FUNCTION test_timestamp_ltz_fn(p_rec test_timestamp_ltz%ROWTYPE)
2438+
RETURN NUMBER
2439+
IS
2440+
BEGIN
2441+
RETURN p_rec.id;
2442+
END;
2443+
SQL
2444+
end
2445+
2446+
after(:all) do
2447+
plsql.execute "DROP FUNCTION test_timestamp_ltz_fn" rescue nil
2448+
plsql.execute "DROP TABLE test_timestamp_ltz" rescue nil
2449+
plsql.logoff
2450+
end
2451+
2452+
it "should remap TIMESTAMP(n) WITH LOCAL TIME ZONE to TIMESTAMP WITH LOCAL TIME ZONE" do
2453+
procedure = PLSQL::Procedure.find(plsql, :test_timestamp_ltz_fn)
2454+
fields = procedure.arguments[0][:p_rec][:fields]
2455+
expect(fields[:ts][:data_type]).to eq("TIMESTAMP WITH LOCAL TIME ZONE")
2456+
end
2457+
end
2458+
24302459
describe "Function with TABLE OF %ROWTYPE parameter defined in package" do
24312460
before(:all) do
24322461
plsql.connect! CONNECTION_PARAMS

0 commit comments

Comments
 (0)