ginjo / rfm

FileMaker to Ruby adapter.
MIT License
45 stars 22 forks source link

Creating a record in a layout with a portal is causing problems #24

Open asppsa opened 9 years ago

asppsa commented 9 years ago

[edited, got my bugs crossed!] Hi there,

I've encountered a problem when trying to create a new record using v3.0.9. This time I've used HTTPie to get the problematic XML, so it should be completely legit. This is on FileMaker 14, so I guess there's a chance that the issue is due to an API change, or even a FileMaker bug ...

Anyway, the offending XML is here. When parsing this XML, I get the following error:

     NoMethodError:
       undefined method `[]' for nil:NilClass

The error comes from here:

     # /home/asp/src/ginjo-rfm/lib/rfm/metadata/datum.rb:26:in `portal_field_element_close_callback'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/sax_parser.rb:387:in `get_callback'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/sax_parser.rb:305:in `receive_end_element'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/sax_parser.rb:779:in `_end_element'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/sax_parser.rb:852:in `sax_parse'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/sax_parser.rb:852:in `block in run_parser'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/sax_parser.rb:852:in `open'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/sax_parser.rb:852:in `run_parser'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/sax_parser.rb:634:in `build'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/sax_parser.rb:627:in `build'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/sax_parser.rb:136:in `parse'
     # /home/asp/src/ginjo-rfm/lib/rfm/utilities/connection.rb:85:in `parse'
     # /home/asp/src/ginjo-rfm/lib/rfm/layout.rb:325:in `get_records'
     # /home/asp/src/ginjo-rfm/lib/rfm/layout.rb:265:in `create'
     # /home/asp/src/ginjo-rfm/lib/rfm/base.rb:260:in `create_from_new'
     # /home/asp/src/ginjo-rfm/lib/rfm/base.rb:273:in `block in create'
     # /home/asp/.gem/ruby/2.1.2/gems/activesupport-4.2.2/lib/active_support/callbacks.rb:88:in `call'
     # /home/asp/.gem/ruby/2.1.2/gems/activesupport-4.2.2/lib/active_support/callbacks.rb:88:in `_run_callbacks'
     # /home/asp/.gem/ruby/2.1.2/gems/activesupport-4.2.2/lib/active_support/callbacks.rb:776:in `_run_create_callbacks'
     # /home/asp/.gem/ruby/2.1.2/gems/activesupport-4.2.2/lib/active_support/callbacks.rb:81:in `run_callbacks'
     # /home/asp/src/ginjo-rfm/lib/rfm/base.rb:270:in `create'
     # /home/asp/src/ginjo-rfm/lib/rfm/base.rb:206:in `save!'

I did a pry and it seems to be baulking at the WLG Current Location Sort By First::Qty field. It looks like it fails because the metadata for the portal is not available in the XML. Like I say, don't know if that's a FM14 thing, or what. I was able to get around it with this patch, but I suppose that will cause problems somewhere else. I have another issue that I'll submit separately.