From b83d54c1d139b14190d22c0514bbcaaa90d2f213 Mon Sep 17 00:00:00 2001 From: cj Date: Fri, 7 Mar 2014 19:20:04 -0600 Subject: [PATCH 01/13] fake rows --- lib/mini_record/auto_schema.rb | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/mini_record/auto_schema.rb b/lib/mini_record/auto_schema.rb index fa63393..39e89cb 100644 --- a/lib/mini_record/auto_schema.rb +++ b/lib/mini_record/auto_schema.rb @@ -5,6 +5,7 @@ def self.included(base) end module ClassMethods + def init_table_definition(connection) #connection.create_table(table_name) unless connection.table_exists?(table_name) @@ -12,13 +13,14 @@ def init_table_definition(connection) when 1 # Rails 3.2 and earlier ActiveRecord::ConnectionAdapters::TableDefinition.new(connection) - when 4 + when 4, -5 # Rails 4 ActiveRecord::ConnectionAdapters::TableDefinition.new(connection.native_database_types, table_name, false, {}) else raise ArgumentError, "Unsupported number of args for ActiveRecord::ConnectionAdapters::TableDefinition.new()" end + end def schema_tables @@ -72,14 +74,49 @@ def fields_in_db end end + def columns_hash + if mini_record_fake_columns + super.merge mini_record_fake_columns + else + super + end + end + + def mini_record_columns + @@_mr_columns ||= {} + @@_mr_columns[table_name] ||= {} + end + + def mini_record_fake_columns + @@_mr_fake_columns ||= {} + @@_mr_fake_columns[table_name] ||= {} + end + def field(*args) return unless connection? options = args.extract_options! type = options.delete(:as) || options.delete(:type) || :string index = options.delete(:index) + fake = options.delete(:fake) || false args.each do |column_name| + # add it it the mini record columns for this table so we can access + # special fields like input_as, used by form builders + mini_record_columns[column_name] = options + + if fake + # allow you to access the field on the instance object + attr_accessor column_name + # create a column that column_hashes will understand (a fake row) + fake_column = ActiveRecord::ConnectionAdapters::Column.new( + column_name.to_s, nil, type, true + ) + # add it to the list of fake columns for this table + mini_record_fake_columns[column_name.to_s] = fake_column + # skip everything else as it's a fake column and don't want it in the db + next + end # Allow custom types like: # t.column :type, "ENUM('EMPLOYEE','CLIENT','SUPERUSER','DEVELOPER')" From 237d4978e1f90e547e027e54411c52200fcec33c Mon Sep 17 00:00:00 2001 From: cj Date: Mon, 7 Jul 2014 20:04:43 -0500 Subject: [PATCH 02/13] change gem name --- mini_record.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mini_record.gemspec b/mini_record.gemspec index ae7866b..f496514 100644 --- a/mini_record.gemspec +++ b/mini_record.gemspec @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__) require "mini_record/version" Gem::Specification.new do |s| - s.name = "mini_record" + s.name = "mini_record-cj" s.version = MiniRecord::VERSION s.authors = ["Davide D'Agostino"] s.email = ["d.dagostino@lipsiasoft.com"] From 552235740fba3b36af32445e4ea8378ae7d8b2d6 Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Tue, 18 Sep 2018 11:21:24 -0500 Subject: [PATCH 03/13] restores the original name of gem --- mini_record.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mini_record.gemspec b/mini_record.gemspec index f496514..ae7866b 100644 --- a/mini_record.gemspec +++ b/mini_record.gemspec @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__) require "mini_record/version" Gem::Specification.new do |s| - s.name = "mini_record-cj" + s.name = "mini_record" s.version = MiniRecord::VERSION s.authors = ["Davide D'Agostino"] s.email = ["d.dagostino@lipsiasoft.com"] From 78dd60075a2f5d900b32ccb115ec0e5640759eeb Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Tue, 18 Sep 2018 00:30:38 -0500 Subject: [PATCH 04/13] adds columns type support for active_record 4.2.x or superior. Fixes the undefined_method type_cast_from_database adding a active record type object that responds to this method --- lib/mini_record/auto_schema.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/mini_record/auto_schema.rb b/lib/mini_record/auto_schema.rb index 39e89cb..1c796bb 100644 --- a/lib/mini_record/auto_schema.rb +++ b/lib/mini_record/auto_schema.rb @@ -92,6 +92,18 @@ def mini_record_fake_columns @@_mr_fake_columns[table_name] ||= {} end + # Lookup for registered ActiveRecord Types + # This in important for rails 4 and 5 due to ActiveRecord converts + # columns into object with the column type. Types depends from Connection + # Adapter. + # activerecord/lib/active_record/type/ + # active_record/connection_adapters + # initialize_type_map defined the available types depending of + # database adapter. + def lookup_cast_type(type) + connection.lookup_cast_type(type) + end + def field(*args) return unless connection? @@ -108,6 +120,10 @@ def field(*args) if fake # allow you to access the field on the instance object attr_accessor column_name + # ActiveRecord 4.2.x maps columns into types. + # Create a column symbol as type produced + # undefined method `type_cast_from_database' for :[boolean|string]:Symbol + type = lookup_cast_type(type) if defined?(ActiveRecord::Type) # create a column that column_hashes will understand (a fake row) fake_column = ActiveRecord::ConnectionAdapters::Column.new( column_name.to_s, nil, type, true From a3a8bdcc0037178b2efc5def2a388b49469c53bf Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Tue, 18 Sep 2018 12:07:24 -0500 Subject: [PATCH 05/13] bumps acdcorp version to 0.3.8 --- lib/mini_record/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mini_record/version.rb b/lib/mini_record/version.rb index a0881d2..d655c0d 100644 --- a/lib/mini_record/version.rb +++ b/lib/mini_record/version.rb @@ -1,3 +1,3 @@ module MiniRecord - VERSION = "0.3.7" + VERSION = "0.3.8" end From 90e777b4c4ac88b45dd38ffbef4c059d7fb8ceda Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Tue, 18 Sep 2018 16:27:42 -0500 Subject: [PATCH 06/13] set activerecord version to latest/stable 4.2 and refactors Gemfile and gemspec --- Gemfile | 13 ------------- mini_record.gemspec | 9 ++++++++- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index 958dd05..c80ee36 100644 --- a/Gemfile +++ b/Gemfile @@ -1,16 +1,3 @@ source "http://rubygems.org" -# Specify your gem's dependencies in mini_record.gemspec -gem 'rake' -gem 'minitest' -gem 'sqlite3' -gem 'mysql2' -gem 'mysql' -gem 'pg' -gem 'activerecord', '<= 3.2' - -group :test do - gem 'foreigner', '>= 1.4.2' -end - gemspec diff --git a/mini_record.gemspec b/mini_record.gemspec index ae7866b..452ded0 100644 --- a/mini_record.gemspec +++ b/mini_record.gemspec @@ -24,5 +24,12 @@ Gem::Specification.new do |s| # specify any dependencies here; for example: # s.add_development_dependency "rspec" - s.add_dependency "activerecord", ">=3.2.0" + s.add_runtime_dependency "activerecord", '~> 4.2' + + s.add_development_dependency 'rake' + s.add_development_dependency 'minitest' + s.add_development_dependency 'sqlite3' + s.add_development_dependency 'mysql2' + s.add_development_dependency 'pg' + s.add_development_dependency 'foreigner', '>= 1.4.2' end From addf16dda0b3a3b97ab000820efd9e43d26b5d1e Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Tue, 18 Sep 2018 16:36:54 -0500 Subject: [PATCH 07/13] documented activerecord support version by branches --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index f59c4c7..4ef6c4c 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,19 @@ class Fox < ActiveRecord::Base end ``` +## Versions + +### ActiveRecord 4.0.5 or lower + +If you are using ruby 2.1 and activerecord lower than or equal to 4.0.5 please +use [fork-stable](https://github.com/acdcorp/mini_record/tree/fork-stable) or +[0.3.7 tag/version](https://github.com/acdcorp/mini_record/tree/v0.3.7) + +### ActiveRecord >= 4.0.5 <= 4.2.10 and Ruby >= 2.3 + +Please use this branch [0.3.8-acdcorp-stable](https://github.com/acdcorp/mini_record/tree/0.3.8-acdcorp-stable) +or [0.3.8 tag/version](https://github.com/acdcorp/mini_record/tree/v0.3.8) + ## Author DAddYE, you can follow me on twitter [@daddye](http://twitter.com/daddye) or take a look at my site [daddye.it](http://www.daddye.it) From 3c34401988d13a915e51cee48c3814b9af98ad78 Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Tue, 18 Sep 2018 16:41:46 -0500 Subject: [PATCH 08/13] bumps mini_record version to 0.3.9 --- lib/mini_record/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mini_record/version.rb b/lib/mini_record/version.rb index d655c0d..ad18dc1 100644 --- a/lib/mini_record/version.rb +++ b/lib/mini_record/version.rb @@ -1,3 +1,3 @@ module MiniRecord - VERSION = "0.3.8" + VERSION = "0.3.9" end From 4279918767c13427236b4b310f54a5e80e40659e Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Tue, 18 Sep 2018 16:46:06 -0500 Subject: [PATCH 09/13] updates the branch name for 0.3 stable version --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 4ef6c4c..2de0f12 100644 --- a/README.md +++ b/README.md @@ -187,8 +187,7 @@ use [fork-stable](https://github.com/acdcorp/mini_record/tree/fork-stable) or ### ActiveRecord >= 4.0.5 <= 4.2.10 and Ruby >= 2.3 -Please use this branch [0.3.8-acdcorp-stable](https://github.com/acdcorp/mini_record/tree/0.3.8-acdcorp-stable) -or [0.3.8 tag/version](https://github.com/acdcorp/mini_record/tree/v0.3.8) +Please use this branch [0.3-acdcorp-stable](https://github.com/acdcorp/mini_record/tree/0.3-acdcorp-stable) ## Author From 7d377fb8954d33d01b4df6050eb4713a72c2ae01 Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Tue, 18 Sep 2018 16:49:18 -0500 Subject: [PATCH 10/13] bumps version to 0.3.10 --- lib/mini_record/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mini_record/version.rb b/lib/mini_record/version.rb index ad18dc1..92aac4b 100644 --- a/lib/mini_record/version.rb +++ b/lib/mini_record/version.rb @@ -1,3 +1,3 @@ module MiniRecord - VERSION = "0.3.9" + VERSION = "0.3.10" end From e261e643a2c1116f8ca4ded0106cd534787c0d73 Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Wed, 24 Mar 2021 00:53:24 -0600 Subject: [PATCH 11/13] updates activerecord version to 4.2.11 --- README.md | 4 ++++ mini_record.gemspec | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2de0f12..06cc562 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,10 @@ use [fork-stable](https://github.com/acdcorp/mini_record/tree/fork-stable) or Please use this branch [0.3-acdcorp-stable](https://github.com/acdcorp/mini_record/tree/0.3-acdcorp-stable) +### ActiveRecord 4.2.11 and Ruby >= 2.5.5 and 2.6.6 + +Please use version 0.3.11 + ## Author DAddYE, you can follow me on twitter [@daddye](http://twitter.com/daddye) or take a look at my site [daddye.it](http://www.daddye.it) diff --git a/mini_record.gemspec b/mini_record.gemspec index 452ded0..231232e 100644 --- a/mini_record.gemspec +++ b/mini_record.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |s| # specify any dependencies here; for example: # s.add_development_dependency "rspec" - s.add_runtime_dependency "activerecord", '~> 4.2' + s.add_runtime_dependency "activerecord", '~> 4.2.11' s.add_development_dependency 'rake' s.add_development_dependency 'minitest' From 0d5e5e98a71b163aa69d8c25a16d5a8c6968ca40 Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Wed, 31 Mar 2021 15:35:52 -0600 Subject: [PATCH 12/13] fixes readme file and versions instructions --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 06cc562..88166e6 100644 --- a/README.md +++ b/README.md @@ -189,9 +189,16 @@ use [fork-stable](https://github.com/acdcorp/mini_record/tree/fork-stable) or Please use this branch [0.3-acdcorp-stable](https://github.com/acdcorp/mini_record/tree/0.3-acdcorp-stable) -### ActiveRecord 4.2.11 and Ruby >= 2.5.5 and 2.6.6 -Please use version 0.3.11 +### ActiveRecord 4.2.11 ruby 2.5.5 and 2.6.6 + +Please use branch [0.3.11-acdcorp-activerecord4.2.11](https://github.com/acdcorp/mini_record/tree/0.3.11-acdcorp-activerecord4.2.11) + +## Development + +Master is the development branch of this gem for acdcorp because we can't +change the official mini_record gem version unless we push our custom +development. ## Author From e1091a877e33c2b036062371e8626315bf32891e Mon Sep 17 00:00:00 2001 From: Bernardo Galindo Date: Mon, 8 Aug 2022 22:06:46 -0500 Subject: [PATCH 13/13] adds support for active record 6.1 --- README.md | 2 ++ mini_record.gemspec | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 88166e6..f52d4b4 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,8 @@ Master is the development branch of this gem for acdcorp because we can't change the official mini_record gem version unless we push our custom development. +Current version support Rails 6.0.1 + ## Author DAddYE, you can follow me on twitter [@daddye](http://twitter.com/daddye) or take a look at my site [daddye.it](http://www.daddye.it) diff --git a/mini_record.gemspec b/mini_record.gemspec index 231232e..eaf3784 100644 --- a/mini_record.gemspec +++ b/mini_record.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |s| # specify any dependencies here; for example: # s.add_development_dependency "rspec" - s.add_runtime_dependency "activerecord", '~> 4.2.11' + s.add_runtime_dependency "activerecord", '~> 6.1.0' s.add_development_dependency 'rake' s.add_development_dependency 'minitest'