Fix SQLite3::SQLException in Quantity ordered scope

CAST(... AS BINARY) is MySQL-specific syntax; SQLite requires BLOB.
Use connection.adapter_name to select the correct cast type.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 12:56:38 +00:00
parent 83b064ef3c
commit 8be9b3eb2f

View File

@@ -66,7 +66,7 @@ class Quantity < ApplicationRecord
self.model.with(numbered: numbered(:parent_id, :name)).with_recursive(arel_table.name => [
numbered.project(
numbered[Arel.star],
numbered.cast(numbered[:child_number], 'BINARY').as('path')
numbered.cast(numbered[:child_number], connection.adapter_name == 'Mysql2' ? 'BINARY' : 'BLOB').as('path')
).where(numbered[root && include_root ? :id : :parent_id].eq(root)),
numbered.project(
numbered[Arel.star],