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

Use ActiveRecord::Base.connection.quote #5

Open
Quantenradierer opened this issue Sep 6, 2019 · 2 comments
Open

Use ActiveRecord::Base.connection.quote #5

Quantenradierer opened this issue Sep 6, 2019 · 2 comments

Comments

@Quantenradierer
Copy link

def dump_value_string(value)

Can be replaced by ActiveRecord::Base.connection.quote?

keys = key_values.collect{ |item| "`#{item[0]}`" }.join(", ")

Can be replaced by
keys = key_values.collect{ |item| ActiveRecord::Base.connection.quote_column_name(item[0]) }.join(", ")

And what's rarely an issue but still, quote the table name: table_name = ActiveRecord::Base.connection.quote_table_name(object.class.table_name)

This also increases support for other databases.

@hunterae
Copy link
Owner

hunterae commented Sep 7, 2019

Awesome @Quantenradierer . I had no idea those utilities existed. I created this gem some time ago and based the original implementation on a blog article I found here: http://invisipunk.blogspot.com/2008/04/activerecord-raw-insertupdate.html.

It looks like those utils go really far back in Rails' versions, so yeah, I'll definitely see if I can make this change pretty soon.

@invisipunk
Copy link

@hunterae So happy someone found that article useful.

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

3 participants