Skip to content

Commit a9a1ca4

Browse files
authored
Merge pull request #1006 from rsov/merging_branch
Merge fixes for AS400 database for Rails 5.2
2 parents 77f4056 + 240e14a commit a9a1ca4

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/arjdbc/db2/adapter.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,17 @@ def prefetch_primary_key?(table_name = nil)
328328
select_one(sql).nil?
329329
end
330330

331+
# @override
332+
def primary_keys(table)
333+
# If no schema in table name is given but present in URL parameter. Use the URL parameter one
334+
# This avoids issues if the table is present in multiple schemas
335+
if table.split(".").size == 1 && schema
336+
table = "#{schema}.#{table}"
337+
end
338+
339+
super
340+
end
341+
331342
def next_sequence_value(sequence_name)
332343
select_value("SELECT NEXT VALUE FOR #{sequence_name} FROM sysibm.sysdummy1")
333344
end

lib/arjdbc/jdbc/adapter.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ def update_lob_value(record, column, value)
358358
# @return [Integer, NilClass]
359359
def last_inserted_id(result)
360360
if result.is_a?(Hash) || result.is_a?(ActiveRecord::Result)
361+
# If table does not have primary key defined
362+
return nil if result.first.blank?
363+
364+
361365
result.first.first[1] # .first = { "id"=>1 } .first = [ "id", 1 ]
362366
else
363367
result

0 commit comments

Comments
 (0)