jeremie-borel/pyfilemaker2

Values for composite field-names stored in wrong object

Closed this issue · 0 comments

If a query-result contains composite field-names (table-name::field-name) and the field-name part is the same as another, non-composite, field-name in the result, the last field in the result-set "wins". Either way, you don't get both values. Also, the table-name is not the name of the layout's base-table (so it does not match self.table in the method modified below).

Here's the fix:

diff --git a/pyfilemaker2/metadata.py b/pyfilemaker2/metadata.py
index 982bf93..dd5f06f 100644
--- a/pyfilemaker2/metadata.py
+++ b/pyfilemaker2/metadata.py
@@ -191,6 +191,7 @@ class FmFieldData(FmFieldBase):
                     obj = obj[ctx]
                 except KeyError:
                     obj[ctx] = self.fm_meta.get_record_class()()
+                    obj = obj[ctx]
             obj[name] = value

     def dump(self):

Example:
I queried a layout, form-images, whose base-table is Form Images, and it contains two fields: Status and Forms::Status, in that order.

In the result-set from pyfilemaker2, there was only a Status field, and it always had the value from Forms::Status.