Skip to content

Issue with 1.2.0/1.2.1 on MariaDB #33

Description

@andyjeffries

I get this error ActiveRecord::StatementInvalid on SolidQueueMonitor::OverviewController#index:

Trilogy::QueryError: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server     
version for the right syntax to use near 'EPOCH FROM created_at) - 1774538672) / 3600 AS INTEGER) AS bucket_idx, COUNT(...'   
at line 1 (trilogy_query_recv)                                                                                                

��
According to Claude (it’s really late where I am and I’m jet lagged already):

This is a known compatibility issue — the EXTRACT(EPOCH FROM ...) syntax is PostgreSQL-specific and doesn't work on MariaDB.
   Let me find the exact source so we can monkey-patch it.
   1   # frozen_string_literal: true                                                     │ adapter?                          
   1   ����������������������������������������������������������������������������������│                                    
   2   # Monkey-patch SolidQueueMonitor::ChartDataService to recognize the Trilogy�������│                                    
   3   # adapter (MariaDB/MySQL) so it uses UNIX_TIMESTAMP instead of the PostgreSQL�����│                                    
   4   # EXTRACT(EPOCH FROM ...) syntax.�������������������������������������������������│                                    
   5   #���������������������������������������������������������������������������������│                                    
   6   # Upstream issue: the gem checks adapter?('mysql') but Trilogy reports its��������│                                    
   7   # adapter_name as "Trilogy", not "MySQL2".����������������������������������������│                                    
   8   ����������������������������������������������������������������������������������│                                    
   9   Rails.application.config.to_prepare do��������������������������������������������│                                    
  10   │ SolidQueueMonitor::ChartDataService.prepend(Module.new do�����������������������│                                    
  11   │ │ private�����������������������������������������������������������������������│                                    
  12   │ │�������������������������������������������������������������������������������│                                    
  13   │ │ def adapter?(name)������������������������������������������������������������│                                    
  14   │ │ │ adapter_name = ActiveRecord::Base.connection.adapter_name.downcase����������│                                    
  15   │ │ │ adapter_name.include?(name) || (name == "mysql" && adapter_name.include?    │                                    
       │ │ │ ("trilogy"))����������������������������������������������������������������│                                    
  16   │ │ end���������������������������������������������������������������������������│                                    
  17   │ end)����������������������������������������������������������������������������│                                    
  18   end

Anyway, it’s late, I’m copy/pasting on an iPad, so I hope this helps in a little way

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions