Project

General

Profile

Bug #8868

Fix "Can't normalize FWD value to use it with direct access." error for FieldReference arguments

Added by Dănuț Filimon 22 days ago. Updated 19 days ago.

Status:
Review
Priority:
Normal
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:

History

#1 Updated by Dănuț Filimon 22 days ago

While testing the unit tests of a customer, I noticed that there are a few instances of FieldReference arguments that will reach DirectAccessHelper.findByUniqueIndex() and those values will throw an exception because DirectAccessHelper.normalizeValue() can't handle them.

Similar to FqlPreprocessor.getFindByRowid() where the value is extracted when there is a FieldReference, normalizeValue() should be able to do the same.

The following patch solves this issue and allows direct access to be used in more cases:

=== modified file 'src/com/goldencode/p2j/persist/orm/DirectAccessHelper.java'
--- old/src/com/goldencode/p2j/persist/orm/DirectAccessHelper.java    2023-12-12 16:08:14 +0000
+++ new/src/com/goldencode/p2j/persist/orm/DirectAccessHelper.java    2024-06-11 06:45:27 +0000
@@ -80,6 +80,7 @@
 import org.h2.jdbc.JdbcConnection;

 import com.goldencode.p2j.oo.lang._BaseObject_;
+import com.goldencode.p2j.persist.FieldReference;
 import com.goldencode.p2j.persist.PersistenceException;
 import com.goldencode.p2j.persist.Record;
 import com.goldencode.p2j.persist.UniqueIndexLookup;
@@ -307,6 +308,12 @@
          // already normalized
          return arg;
       }
+      
+      if (arg instanceof FieldReference)
+      {
+         arg = ((FieldReference) arg).get();
+      }
+      
       if (arg instanceof BaseDataType)
       {
          if (((BaseDataType) arg).isUnknown())

#3 Updated by Dănuț Filimon 22 days ago

  • Assignee set to Dănuț Filimon
  • Status changed from New to WIP

#4 Updated by Dănuț Filimon 22 days ago

  • Status changed from WIP to Review

#5 Updated by Greg Shah 22 days ago

Eric: Please review.

#6 Updated by Dănuț Filimon 21 days ago

  • % Done changed from 0 to 100

Created 8868a and committed the patch from #8868-1 to 8868a/rev.15280.

#7 Updated by Eric Faulhaber 20 days ago

Greg Shah wrote:

Eric: Please review.

Code review 8868a/15280:

H2 direct access is not an area of the code I am that familiar with, but the change seems simple and safe enough. I am ok with it.

Are there any other types which could be returned by UniqueIndexLookup.getValues which, like FieldReference before this fix, are not currently accounted for?

A pre-existing coding standard issue: please use wildcards for the import statements, unless more specific names are needed for disambiguation.

#8 Updated by Dănuț Filimon 19 days ago

Eric Faulhaber wrote:

Greg Shah wrote:

Eric: Please review.

Code review 8868a/15280:

Are there any other types which could be returned by UniqueIndexLookup.getValues which, like FieldReference before this fix, are not currently accounted for?

I am not sure, maybe Alexandru can answer this?

A pre-existing coding standard issue: please use wildcards for the import statements, unless more specific names are needed for disambiguation.

Committed 8868a/rev.15281, added wildcard import statement (I did not add a history entry for this).

Also available in: Atom PDF