Class: LlmCostTracker::Ledger::Rollups::UpsertSql

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_cost_tracker/ledger/rollups/upsert_sql.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ UpsertSql

Returns a new instance of UpsertSql.



13
14
15
# File 'lib/llm_cost_tracker/ledger/rollups/upsert_sql.rb', line 13

def initialize(model)
  @model = model
end

Class Method Details

.call(model) ⇒ Object



9
10
11
# File 'lib/llm_cost_tracker/ledger/rollups/upsert_sql.rb', line 9

def self.call(model)
  new(model).call
end

Instance Method Details

#callObject



17
18
19
20
21
22
# File 'lib/llm_cost_tracker/ledger/rollups/upsert_sql.rb', line 17

def call
  return Arel.sql(mysql_sql) if Ledger::Schema::Adapter.mysql?(connection)
  return Arel.sql(postgres_sql) if Ledger::Schema::Adapter.postgresql?(connection)

  Ledger::Schema::Adapter.ensure_supported!(connection)
end