Skip to content

Commit e2367ef

Browse files
committed
fix(sqlite3): move SQLite3Integer to adapter class
This ensures the proper namespace which is needed for marshal/unmarshal
1 parent eb049d9 commit e2367ef

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

lib/arjdbc/sqlite3/adapter.rb

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,6 @@ def bind_params_length
373373
999
374374
end
375375

376-
def initialize_type_map(m = type_map)
377-
super
378-
register_class_with_limit m, %r(int)i, SQLite3Integer
379-
end
380-
381376
def table_structure(table_name)
382377
structure = exec_query("PRAGMA table_info(#{quote_table_name(table_name)})", "SCHEMA")
383378
raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty?
@@ -573,18 +568,6 @@ def configure_connection
573568
execute("PRAGMA foreign_keys = ON", "SCHEMA")
574569
end
575570

576-
# DIFFERENCE: FQN
577-
class SQLite3Integer < ::ActiveRecord::Type::Integer # :nodoc:
578-
private
579-
def _limit
580-
# INTEGER storage class can be stored 8 bytes value.
581-
# See https://www.sqlite.org/datatype3.html#storage_classes_and_datatypes
582-
limit || 8
583-
end
584-
end
585-
586-
# DIFFERENCE: FQN
587-
::ActiveRecord::Type.register(:integer, SQLite3Integer, adapter: :sqlite3)
588571
end
589572
# DIFFERENCE: A registration here is moved down to concrete class so we are not registering part of an adapter.
590573
end
@@ -743,5 +726,23 @@ def combine_multi_statements(total_sql)
743726
total_sql
744727
end
745728
end
729+
730+
def initialize_type_map(m = type_map)
731+
super
732+
register_class_with_limit m, %r(int)i, SQLite3Integer
733+
end
734+
735+
# DIFFERENCE: FQN
736+
class SQLite3Integer < ::ActiveRecord::Type::Integer # :nodoc:
737+
private
738+
def _limit
739+
# INTEGER storage class can be stored 8 bytes value.
740+
# See https://www.sqlite.org/datatype3.html#storage_classes_and_datatypes
741+
limit || 8
742+
end
743+
end
744+
745+
# DIFFERENCE: FQN
746+
::ActiveRecord::Type.register(:integer, SQLite3Integer, adapter: :sqlite3)
746747
end
747748
end

0 commit comments

Comments
 (0)