Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model.new fields missing if done after a failed Model.find #28

Open
emptyflask opened this issue Jul 18, 2015 · 5 comments
Open

Model.new fields missing if done after a failed Model.find #28

emptyflask opened this issue Jul 18, 2015 · 5 comments

Comments

@emptyflask
Copy link

If I run Mover.new first, I get the expected behavior, and @model.field_names is correctly populated.

Running Mover.find(...) with an empty result set and then Mover.new creates an empty hash, and @model.field_names is empty.

Seems like Rfm is relying on the first connection to Filemaker to populate the layout, even if that connection doesn't return any layout data.

Tested with Ruby 2.2.0, Filemaker 13, rfm 3.0.9

@ginjo
Copy link
Owner

ginjo commented Sep 9, 2015

@emptyflask, @traels, sounds like the meta data is just not loading when it should... which of course causes all kinds of problems down the line. I'll have to review the code to find out why it's not loading, but I see two possible solutions.

  • Raise an exception when the meta doesn't load when it should.
  • Keep trying to load the meta, when it's needed, no matter what the situation.

I'd like to find something in the middle of those two - make meta loading more robust/reliable, while a true failure to load would raise an exception. Comments welcome if anyone sees problems with that approach.

@asppsa, just including you here in case you think the portal problem could also be related to missing meta data.

@asppsa
Copy link

asppsa commented Sep 9, 2015

Hi there. #24 is definitely a metadata-related issue. The exception raised is the result of trying to access non-existent data in resultset.portal_meta -- see line 26 of datum.rb.

@emptyflask
Copy link
Author

Linking 73b378a to this issue. I'll try to test this later today...

@ginjo
Copy link
Owner

ginjo commented Sep 9, 2015

Ok, so to sum up what I did in the commit mentioned above...

The meta missing problem is more of a design flaw than a specific coding bug. I originally had the layout object looking at the first-returned resultset meta, when possible, for things like field names and portal meta. The problem with this is that a null found set returned from FM doesn't have any resultset meta - it is instead considered an error (401).

So I adjusted the layout object to verify that any stored resultset meta is valid, and if not, get a new empty resultset using FM's -view action (returns a fully valid - but empty - resultset).

Meanwhile, the 401 error is silent by default but can be made noisy with config :raise_on_401 => true

I'll follow up later today and also address the PR's. Thanks all for the feedback.

@traels
Copy link

traels commented Sep 10, 2015

Thank you! Looking forward to remove monkey patches from my code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants