shioyama/mobility

Destruction of DB records with linked translation records fails (with a strange SQL query)

john-999 opened this issue · 2 comments

Destruction of DB records with linked translations fails (with a strange SQL query).

Context

  • Using Rails, with table backend
  • gem mobility (1.2.9)
  • gem rails (7.0.3.1)
  • Table names: Issues, Issue_translations

Expected Behavior

In the Rails console, this should destroy a record from Issues and all linked records from Issue_translations:

> i = Issue.first
> i.destroy

Actual Behavior

In the Rails console:

> i = Issue.first
> i.destroy
  TRANSACTION (0.3ms)  BEGIN
  Issue::Translation Load (0.5ms)  SELECT `issue_translations`.* FROM `issue_translations` WHERE `issue_translations`.`issue_id` = '46e5afce-1a45-4313-ac39-55d236d78876'
  Issue::Translation Destroy (0.8ms)  DELETE FROM `issue_translations` WHERE `issue_translations`.`` IS NULL
  TRANSACTION (0.3ms)  ROLLBACK                 
/home/user/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/mysql2-0.5.4/lib/mysql2/client.rb:148:in `_query': Mysql2::Error: Unknown column 'issue_translations.' in 'where clause' (ActiveRecord::StatementInvalid)
/home/user/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/mysql2-0.5.4/lib/mysql2/client.rb:148:in `_query': Unknown column 'issue_translations.' in 'where clause' (Mysql2::Error)

Mobility has tests for this, you must have something else in your model or some strange configuration.

I'm closing, please provide a failing test or steps to reproduce otherwise there's nothing I can do.