1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
Description: Fix test for activerecord 4.2
This patch fix tests related with the use of activerecord 4.2,
specially for problems generated by type_cast_from_user,
type_cast_from_database.
This patch was created using two merge requests already opened on the
upstream, but not accepted yet.
Origin: https://github.com/nulldb/nulldb/pull/62,
https://github.com/nulldb/nulldb/pull/59
Author: Lucas Albuquerque Medeiros de Moura <lucas.moura128@gmail.com>
Last-updated: 2016-03-05
Index: ruby-activerecord-nulldb-adapter/lib/active_record/connection_adapters/nulldb_adapter/core.rb
===================================================================
--- ruby-activerecord-nulldb-adapter.orig/lib/active_record/connection_adapters/nulldb_adapter/core.rb 2016-03-05 17:45:05.705682049 -0300
+++ ruby-activerecord-nulldb-adapter/lib/active_record/connection_adapters/nulldb_adapter/core.rb 2016-03-05 17:45:40.149680542 -0300
@@ -129,14 +129,26 @@
Kernel.load(schema_path)
end
+ takes_cast_type = defined?(ActiveRecord::Type::Value)
+
if table = @tables[table_name]
table.columns.map do |col_def|
- ActiveRecord::ConnectionAdapters::NullDBAdapter::Column.new(
- col_def.name.to_s,
- col_def.default,
- col_def.type,
- col_def.null
- )
+ if takes_cast_type
+ ActiveRecord::ConnectionAdapters::NullDBAdapter::Column.new(
+ col_def.name.to_s,
+ col_def.default,
+ lookup_cast_type(col_def.type),
+ col_def.type,
+ col_def.null
+ )
+ else
+ ActiveRecord::ConnectionAdapters::NullDBAdapter::Column.new(
+ col_def.name.to_s,
+ col_def.default,
+ col_def.type,
+ col_def.null
+ )
+ end
end
else
[]
@@ -181,7 +193,7 @@
def delete(statement, name=nil, binds = [])
with_entry_point(:delete) do
- super(statement, name)
+ super(statement, name).length
end
end
Index: ruby-activerecord-nulldb-adapter/spec/nulldb_spec.rb
===================================================================
--- ruby-activerecord-nulldb-adapter.orig/spec/nulldb_spec.rb 2016-03-05 17:45:05.705682049 -0300
+++ ruby-activerecord-nulldb-adapter/spec/nulldb_spec.rb 2016-03-05 17:45:05.701682049 -0300
@@ -249,7 +249,7 @@
def should_have_column(klass, col_name, col_type)
col = klass.columns_hash[col_name.to_s]
- expect(col.type).to eq col_type
+ expect(col.sql_type).to eq col_type
end
|