chicks / sugarcrm

A ruby based REST Client for SugarCRM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Searching for Project by name broken

roboyak opened this issue · comments

Nice work, fantastic gem for the ruby community, I came across this issue while using gem version 0.9.18:

Searching for Project by name broken using the finders:

broken

SugarCRM::Project.find_by_name("Netflix")

SugarCRM logs are showing a pluralized table name when it shouldn't be:

AND jt2.deleted=0 where (projects.name = 'Netflix') AND project.deleted=0:
MySQL error 1054: Unknown column 'projects.name' in 'where clause'

Looks like it should be where (project.name = 'Netflix') the singular version.

work around

This alternative method does work however when searching for projects by name:

SugarCRM.connection.get_entry_list(
"Project",
"project.name = 'Netflix'"
)

Ooof, thanks. Not sure if I'll ever fix this one but good to know!

If you can point me at the section of code where you think it might be I'll create a pull request for you.

So I haven't dug into this, but here's my best guess: We use the Sugar metadata to build dynamic finder methods (look here: https://github.com/chicks/sugarcrm/blob/master/lib/sugarcrm/finders/finder_methods.rb#L161). In 99% of the cases, the table name matches the module name, except this case. You will need to update this line: https://github.com/chicks/sugarcrm/blob/master/lib/sugarcrm/finders/finder_methods.rb#L100 to reference the table name, instead of the module name.

Please run the unit tests before submitting!

Hope that helps!

Cheers,

-Charles

no problem. thank for the pointers.