oracle-enhanced icon indicating copy to clipboard operation
oracle-enhanced copied to clipboard

#write_lobs called only on update but not on create

Open akostadinov opened this issue 4 years ago • 1 comments

I'm not exactly sure whether this is an issue or expected behavior. I didn't observe any error and I'm not an experienced Oracle dba. It just looks strange.

Steps to reproduce

run test should serialize LOBs when creating a record from #2203

Expected behavior

#write_lobs is called

  TestEmployee Create (77.7ms)  INSERT INTO "TEST_EMPLOYEES" ("FIRST_NAME", "LAST_NAME", "SIGNATURE", "ID") VALUES (:a1, :a2, :a3, :a4)  [["first_name", "Peter"], ["last_name", "Doe"], ["signature", "cGV0ZXInc3NpZ25hdHVyZQ==\n"], ["id", 1]]
  Writable Large Object (2.4ms)  SELECT "SIGNATURE" FROM "TEST_EMPLOYEES" WHERE "ID" = 1 FOR UPDATE

Actual behavior

#write_lobs is not called

  TestEmployee Create (77.7ms)  INSERT INTO "TEST_EMPLOYEES" ("FIRST_NAME", "LAST_NAME", "SIGNATURE", "ID") VALUES (:a1, :a2, :a3, :a4)  [["first_name", "Peter"], ["last_name", "Doe"], ["signature", "cGV0ZXInc3NpZ25hdHVyZQ==\n"], ["id", 1]]

System configuration

Rails version: Same as test code in master.

Oracle enhanced adapter version: Master branch.

Ruby version: 2.7.3p183

Oracle Database version: 19.3.0

akostadinov avatar Dec 07 '21 18:12 akostadinov

I see that the write_lob hooks are only registered on UPDATE. Is there any special reason for that? What is the reason not to be registered on SAVE as well?

https://github.com/rsim/oracle-enhanced/blob/master/lib/active_record/connection_adapters/oracle_enhanced/lob.rb#L14-L15

akostadinov avatar Feb 03 '22 16:02 akostadinov