activerecord_views
activerecord_views copied to clipboard
.view_populated? throws an error in test environment
I have materialized_view (postgres) working perfectly in development environment, but loading test envrionment fails in initializer I defined:
LeaseRequestsSearch.refresh_view!(concurrent: :auto) if LeaseRequestsSearch.view_populated?
The error is:
SELECT class_name, checksum, options FROM active_record_views WHERE name = 'lease_requests_searches'
ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "lease_requests_searches"
LINE 1: ...um, options FROM active_record_views WHERE name = 'lease_req...
I'm not sure how that is possible: table name is clearly not an integer. And it works perfectly well in development environment!
That’s a real strange one.
Does the active_record_views table exist in your test database? If so, what does \d active_record_views (in psql) look like?
Are you using config.active_record.schema_format = :sql?
I cannot reproduce this. I assume there must have been something else modifying the production schema.