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

Undefined method map for nil when config.active_record.query_log_tags_enabled is true #117

Closed
MaksJS opened this issue Jan 1, 2024 · 4 comments

Comments

@MaksJS
Copy link

MaksJS commented Jan 1, 2024

On Rails 7.1, when setting config.active_record.query_log_tags_enabled to true, I get this error:

undefined method map' for nil`

        def type_casted_binds(binds)
          binds.map do |value|
            if ActiveModel::Attribute === value
              type_cast(value.value_for_database)
            else

in [activerecord (7.1.2) lib/active_record/connection_adapters/abstract/quoting.rb:235:in type_casted_binds']`

We always go into this line:

 result = connection.select_all(sanitize_sql([ query, values ]), "#{name} Load", nil, preparable: false)

and binds are nil because connection.prepare_statements? is false, due to https://github.com/rails/rails/blob/581074c40d0989ff1d981086043b40dc8daa4888/activerecord/lib/active_record/railtie.rb#L422

@MaksJS
Copy link
Author

MaksJS commented Jan 2, 2024

Ok I see there's already a pending fix: #112

@djmb
Copy link
Collaborator

djmb commented Jan 4, 2024

@MaksJS - I've merged that fix into main - could you check if it resolves this for you? 🙏

@MaksJS MaksJS changed the title undefined method `map' for nil when config.active_record.cache_query_log_tags = true undefined method `map' for nil when config.active_record.query_log_tags_enabled = true Jan 4, 2024
@MaksJS MaksJS changed the title undefined method `map' for nil when config.active_record.query_log_tags_enabled = true Undefined method map for nil when config.active_record.query_log_tags_enabled is true Jan 4, 2024
@MaksJS
Copy link
Author

MaksJS commented Jan 4, 2024

@djmb Yes it does 🎉 Thanks a lot. Could you release a new version?

@djmb
Copy link
Collaborator

djmb commented Jan 8, 2024

Hi @MaksJS - I've just released v0.3.0.

@djmb djmb closed this as completed Jan 8, 2024
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