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

CartoDB::Connection.query chokes on columns named 'class' #10

Open
th3james opened this issue Mar 28, 2012 · 1 comment
Open

CartoDB::Connection.query chokes on columns named 'class' #10

th3james opened this issue Mar 28, 2012 · 1 comment

Comments

@th3james
Copy link

If the sql query returns a column named 'class', the CartoDB::Client::Utils.parse_json breaks on line 10:
json = ::JSON.parse(response.body, :object_class => CartoDB::Types::Metadata, :symbolize_names => true)

Looks like it's because CartoDB::Types::Metadata defines a method for each column name on itself, which means it then overwrites it's own class variable:

    # cartodb/types/metadata.rb:23
    # if key is 'class', we just overwrote self.class :-S
    self.class.send :define_method, "#{key}" do
       self[key.to_sym]
    end

Probably means there are problems with other ruby reserved words?

@Ferdev
Copy link
Contributor

Ferdev commented Apr 6, 2012

Hey James, thanks for this report.

Indeed, the ruby client can't handle cartodb column named with ruby reserved words.

I've just pushed a patch with a workaround to this issue: it adds an underscore to the end of each column name matching a ruby reserved word. But just when retreiving data from the database.

Please, let me know if this solves your problem to close this issue.

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

2 participants