activerecord-ignored_columns 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/MIT-LICENSE +1 -1
- data/README.md +31 -8
- data/Rakefile +1 -1
- data/lib/activerecord/ignored_columns/model_schema.rb +2 -1
- data/lib/activerecord/ignored_columns/query_methods.rb +11 -4
- data/lib/activerecord/ignored_columns/railtie.rb +7 -7
- data/lib/activerecord/ignored_columns/version.rb +2 -2
- metadata +20 -6
- data/lib/tasks/activerecord/ignored_columns_tasks.rake +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60079b7a4f640136599f6cefae3a7e387c5ccbfa
|
4
|
+
data.tar.gz: bef78372c460f1e85e83319532b02a4a97230442
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5e20c3edd7c0c43beccb528038750de607167cfe11176574521ad82be0f2c7a3606d37c308b0c867560a856a818ff9bfe5f5aef29a3511ff23f14c3e0cda93c
|
7
|
+
data.tar.gz: 1a3dfe98983acb3cac9ef4cdf3a9b7c40441bd9fff7b5c78183590cd61796b28a942eae2e47a5cc9bad28238a703e29b98585e2096a30147478cf4d5276b61bf
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## [0.2.0](https://github.com/yasaichi/activerecord-ignored_columns/releases/tag/v0.2.0) (July 6, 2019)
|
4
|
+
|
5
|
+
### Enhancements
|
6
|
+
|
7
|
+
- [Add support of Rails 4.0](https://github.com/yasaichi/activerecord-ignored_columns/pull/2)
|
8
|
+
|
9
|
+
### Breaking changes
|
10
|
+
|
11
|
+
- Rename `Activerecord` to `ActiveRecord`
|
12
|
+
- Remove an unused Rake task
|
13
|
+
|
14
|
+
## [0.1.0](https://github.com/yasaichi/activerecord-ignored_columns/releases/tag/v0.1.0) (July 5, 2019)
|
15
|
+
|
16
|
+
- The initial release
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,17 @@
|
|
1
|
-
#
|
2
|
-
Short description and motivation.
|
1
|
+
# activerecord-ignored_columns
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
[](http://badge.fury.io/rb/activerecord-ignored_columns)
|
4
|
+
[](https://travis-ci.org/yasaichi/activerecord-ignored_columns)
|
5
|
+
[](https://codeclimate.com/github/yasaichi/activerecord-ignored_columns)
|
6
|
+
[](https://codeclimate.com/github/yasaichi/activerecord-ignored_columns/coverage)
|
7
|
+
|
8
|
+
`activerecord-ignored_columns` is a backport of `ActiveRecord::Base.ignored_columns` (introduced in
|
9
|
+
Rails 5) into Rails 4.
|
10
|
+
You can also use this gem for Rails 5.0 because it fixes one serious bug in the version (see
|
11
|
+
[PR #30980](https://github.com/rails/rails/pull/30980)).
|
6
12
|
|
7
13
|
## Installation
|
14
|
+
|
8
15
|
Add this line to your application's Gemfile:
|
9
16
|
|
10
17
|
```ruby
|
@@ -12,17 +19,33 @@ gem 'activerecord-ignored_columns'
|
|
12
19
|
```
|
13
20
|
|
14
21
|
And then execute:
|
22
|
+
|
15
23
|
```bash
|
16
24
|
$ bundle
|
17
25
|
```
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Set columns names that a model should ignore as follows:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
class UserProfile < ActiveRecord::Base
|
33
|
+
self.ignored_columns = %i(full_name)
|
34
|
+
end
|
22
35
|
```
|
23
36
|
|
37
|
+
Ignored columns won't have attribute accessors defined, and won't be referenced in SQL queries.
|
38
|
+
|
24
39
|
## Contributing
|
25
|
-
|
40
|
+
|
41
|
+
You should follow the steps below.
|
42
|
+
|
43
|
+
1. [Fork the repository](https://help.github.com/articles/fork-a-repo/)
|
44
|
+
2. Create a feature branch: `git checkout -b add-new-feature`
|
45
|
+
3. Commit your changes: `git commit -am 'Add new feature'`
|
46
|
+
4. Push the branch: `git push origin add-new-feature`
|
47
|
+
5. [Send us a pull request](https://help.github.com/articles/about-pull-requests/)
|
26
48
|
|
27
49
|
## License
|
50
|
+
|
28
51
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ require "rdoc/task"
|
|
10
10
|
|
11
11
|
RDoc::Task.new(:rdoc) do |rdoc|
|
12
12
|
rdoc.rdoc_dir = "rdoc"
|
13
|
-
rdoc.title = "
|
13
|
+
rdoc.title = "ActiveRecord::IgnoredColumns"
|
14
14
|
rdoc.options << "--line-numbers"
|
15
15
|
rdoc.rdoc_files.include("README.md")
|
16
16
|
rdoc.rdoc_files.include("lib/**/*.rb")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module ActiveRecord
|
4
4
|
module IgnoredColumns
|
5
5
|
module ModelSchema
|
6
6
|
def self.included(active_record_base)
|
@@ -11,6 +11,7 @@ module Activerecord
|
|
11
11
|
end
|
12
12
|
|
13
13
|
module ClassMethods
|
14
|
+
# Override
|
14
15
|
def columns
|
15
16
|
@columns ||= super.reject { |column| ignored_columns.include?(column.name) }
|
16
17
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module ActiveRecord
|
4
4
|
module IgnoredColumns
|
5
5
|
module QueryMethods
|
6
6
|
def self.included(active_record_relation)
|
@@ -8,13 +8,20 @@ module Activerecord
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module PrependMethods
|
11
|
-
|
12
|
-
|
11
|
+
# Override
|
12
|
+
private def build_select(arel, selects = [])
|
13
|
+
if !selects.empty? || select_values.any? || !klass.ignored_columns.any?
|
14
|
+
return former_build_select_implementation? ? super : super(arel)
|
15
|
+
end
|
13
16
|
|
14
17
|
arel.project(*klass.column_names.map { |name|
|
15
|
-
table[
|
18
|
+
table[klass.attribute_aliases[name] || name]
|
16
19
|
})
|
17
20
|
end
|
21
|
+
|
22
|
+
private def former_build_select_implementation?
|
23
|
+
@former_build_select_implementation ||= method(:build_select).super_method.arity == 2
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
20
27
|
end
|
@@ -5,20 +5,20 @@ require "rails/railtie"
|
|
5
5
|
require_relative "model_schema"
|
6
6
|
require_relative "query_methods"
|
7
7
|
|
8
|
-
module
|
8
|
+
module ActiveRecord
|
9
9
|
module IgnoredColumns
|
10
10
|
class Railtie < ::Rails::Railtie
|
11
11
|
initializer "active_record.ignored_columns" do
|
12
12
|
::ActiveSupport.on_load(:active_record) do
|
13
|
-
rails_version = Rails.respond_to?(:gem_version) ?
|
14
|
-
Rails.gem_version : Gem::Version.create(Rails.version)
|
13
|
+
rails_version = ::Rails.respond_to?(:gem_version) ?
|
14
|
+
::Rails.gem_version : ::Gem::Version.create(::Rails.version)
|
15
15
|
|
16
|
-
if rails_version < Gem::Version.create("5")
|
17
|
-
include ::
|
16
|
+
if rails_version < ::Gem::Version.create("5")
|
17
|
+
include ::ActiveRecord::IgnoredColumns::ModelSchema
|
18
18
|
end
|
19
19
|
|
20
|
-
if rails_version < Gem::Version.create("5.1")
|
21
|
-
::ActiveRecord::Relation.include(::
|
20
|
+
if rails_version < ::Gem::Version.create("5.1")
|
21
|
+
::ActiveRecord::Relation.include(::ActiveRecord::IgnoredColumns::QueryMethods)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-ignored_columns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Yuichi Goto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4.
|
19
|
+
version: '4.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '5.1'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '4.
|
29
|
+
version: '4.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '5.1'
|
@@ -100,6 +100,20 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: simplecov
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
103
117
|
- !ruby/object:Gem::Dependency
|
104
118
|
name: sqlite3
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,13 +128,14 @@ dependencies:
|
|
114
128
|
- - "<"
|
115
129
|
- !ruby/object:Gem::Version
|
116
130
|
version: 1.4.0
|
117
|
-
description: Backport of ActiveRecord::Base.ignored_columns
|
131
|
+
description: Backport of ActiveRecord::Base.ignored_columns into Rails 4 and 5.0
|
118
132
|
email:
|
119
133
|
- yasaichi@users.noreply.github.com
|
120
134
|
executables: []
|
121
135
|
extensions: []
|
122
136
|
extra_rdoc_files: []
|
123
137
|
files:
|
138
|
+
- CHANGELOG.md
|
124
139
|
- MIT-LICENSE
|
125
140
|
- README.md
|
126
141
|
- Rakefile
|
@@ -129,7 +144,6 @@ files:
|
|
129
144
|
- lib/activerecord/ignored_columns/query_methods.rb
|
130
145
|
- lib/activerecord/ignored_columns/railtie.rb
|
131
146
|
- lib/activerecord/ignored_columns/version.rb
|
132
|
-
- lib/tasks/activerecord/ignored_columns_tasks.rake
|
133
147
|
homepage: https://github.com/yasaichi/activerecord-ignored_columns
|
134
148
|
licenses:
|
135
149
|
- MIT
|