squint 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98ccf8823024cfaf1d97d0a7042dcb6269af96158ade06703aedf79b3e158447
4
- data.tar.gz: 1370797c3fa4b327983125277f6abe717f3b8b79e6e7bf38c9994ead82300a2b
3
+ metadata.gz: f1a001a14acd2fc3e2ca16adbb14999e7c0955f7588f7bf2b24ea6b459020cd7
4
+ data.tar.gz: 68a54fa15e06555a8c0320aadac4a9578fbb134f2abb34a4908d9a4f2c034d98
5
5
  SHA512:
6
- metadata.gz: b32b509cf15138f03ea7215fab15271c97a0ae1b17d98743a2ba2f2c02eba47561d5e276cd3fe62f18ccbf90fdcbe283e3291855697e02fc7def8255b29282da
7
- data.tar.gz: 9ab6e3389ec91dec76d90244da33a010b87d5d4d14f27ba58940f821e690a7abfaffe8599cd57a7cd14fd212773fe62232a497dc52293b37fee0c7145e53ad0f
6
+ metadata.gz: f9fcb29b013d12a51aaff4dfed8674a76471ff5eb9e6d92727eeae7ff585c51dc4edb0ef53cb4fdefcf7b6b059391e5bf950c03d659b26d0057c6c32b4567c97
7
+ data.tar.gz: 86cbf3a386e89e2d0d2da91fe585c94dc0d53eeaad4fdfda75ccff26dc14147056500a369fa8380f1fc4e85b941d92a86d61d9b74a79b0353ea551a5b76e4f75
@@ -92,6 +92,17 @@
92
92
  "contributions": [
93
93
  "review"
94
94
  ]
95
+ },
96
+ {
97
+ "login": "jamescook",
98
+ "name": "James Cook",
99
+ "avatar_url": "https://avatars1.githubusercontent.com/u/4067?s=460&u=cb404cc0f1737c2fc53411e300cc8e158ef29295&v=4",
100
+ "profile": "https://github.com/jamescook",
101
+ "contributions": [
102
+ "code",
103
+ "test",
104
+ "review"
105
+ ]
95
106
  }
96
107
  ]
97
108
  }
@@ -27,7 +27,7 @@ module Squint
27
27
  reln = args.inject([]) do |memo, arg|
28
28
  if arg.is_a?(Hash)
29
29
  arg.keys.each do |key|
30
- if arg[key].is_a?(Hash) && HASH_DATA_COLUMNS[key]
30
+ if arg[key].is_a?(Hash) && klass::HASH_DATA_COLUMNS[key]
31
31
  memo << klass.squint_hash_field_reln(key => arg[key])
32
32
  else
33
33
  save_args[0] ||= {}
@@ -70,7 +70,7 @@ module Squint
70
70
  # put together a list of columns in this model
71
71
  # that are hstore, json, or jsonb and will benefit from
72
72
  # searchability
73
- HASH_DATA_COLUMNS = base.columns_hash.keys.map do |col_name|
73
+ base::HASH_DATA_COLUMNS = base.columns_hash.keys.map do |col_name|
74
74
  if %w[hstore json jsonb].include?(base.columns_hash[col_name].sql_type)
75
75
  [col_name.to_sym, base.columns_hash[col_name].sql_type]
76
76
  end
@@ -91,7 +91,7 @@ module Squint
91
91
  def self.squint_hash_field_reln(*args)
92
92
  temp_attr = args[0]
93
93
  contains_nil = false
94
- column_type = HASH_DATA_COLUMNS[args[0].keys.first]
94
+ column_type = self::HASH_DATA_COLUMNS[args[0].keys.first]
95
95
  column_name_segments = []
96
96
  quote_char = '"'.freeze
97
97
  while temp_attr.is_a?(Hash)
@@ -1,3 +1,3 @@
1
1
  module Squint
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "2.0.0".freeze
3
3
  end
data/readme.md CHANGED
@@ -25,7 +25,7 @@
25
25
  - [Credits](#credits)
26
26
 
27
27
  ## Status
28
- [![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors)
28
+ [![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors)
29
29
  [![CircleCI](https://circleci.com/gh/ProctorU/squint.svg?style=svg)](https://circleci.com/gh/ProctorU/squint)
30
30
 
31
31
  ## Quick Start
@@ -158,9 +158,9 @@ columns exists, so don't use those with StoreXT + Squint
158
158
  Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
159
159
 
160
160
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
161
- | [<img src="https://avatars2.githubusercontent.com/u/864581?v=3" width="100px;"/><br /><sub>Kevin Brown</sub>](https://github.com/chevinbrown)<br />[🎨](#design-chevinbrown "Design") [👀](#review-chevinbrown "Reviewed Pull Requests") | [<img src="https://avatars2.githubusercontent.com/u/1741179?v=3" width="100px;"/><br /><sub>Andrew Fomera</sub>](http://andrewfomera.com)<br />[👀](#review-king601 "Reviewed Pull Requests") | [<img src="https://avatars2.githubusercontent.com/u/708692?v=3" width="100px;"/><br /><sub>Ryan T. Hosford</sub>](https://github.com/rthbound)<br />[💻](https://github.com/ProctorU/squint/commits?author=rthbound "Code") | [<img src="https://avatars2.githubusercontent.com/u/1785682?v=3" width="100px;"/><br /><sub>Matthew Jaeh</sub>](https://github.com/Jaehdawg)<br />[🎨](#design-Jaehdawg "Design") [👀](#review-Jaehdawg "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/3933204?v=3" width="100px;"/><br /><sub>Justin Licata</sub>](https://twitter.com/justinlicata)<br />[💻](https://github.com/ProctorU/squint/commits?author=licatajustin "Code") [🎨](#design-licatajustin "Design") [📖](https://github.com/ProctorU/squint/commits?author=licatajustin "Documentation") [👀](#review-licatajustin "Reviewed Pull Requests") | [<img src="https://avatars3.githubusercontent.com/u/24704300?v=4" width="100px;"/><br /><sub>Kyle Miracle</sub>](https://github.com/kmiracle86)<br />[🐛](https://github.com/ProctorU/squint/issues?q=author%3Akmiracle86 "Bug reports") [👀](#review-kmiracle86 "Reviewed Pull Requests") | [<img src="https://avatars2.githubusercontent.com/u/97011?v=3" width="100px;"/><br /><sub>David H. Wilkins</sub>](http://conecuh.com)<br />[💬](#question-dwilkins "Answering Questions") [🐛](https://github.com/ProctorU/squint/issues?q=author%3Adwilkins "Bug reports") [💻](https://github.com/ProctorU/squint/commits?author=dwilkins "Code") [🎨](#design-dwilkins "Design") [📖](https://github.com/ProctorU/squint/commits?author=dwilkins "Documentation") [💡](#example-dwilkins "Examples") [👀](#review-dwilkins "Reviewed Pull Requests") [⚠️](https://github.com/ProctorU/squint/commits?author=dwilkins "Tests") |
161
+ | [<img src="https://avatars2.githubusercontent.com/u/864581?v=3" width="100px;"/><br /><sub>Kevin Brown</sub>](https://github.com/chevinbrown)<br />[🎨](#design-chevinbrown "Design") [👀](#review-chevinbrown "Reviewed Pull Requests") | [<img src="https://avatars2.githubusercontent.com/u/1741179?v=3" width="100px;"/><br /><sub>Andrew Fomera</sub>](http://andrewfomera.com)<br />[👀](#review-king601 "Reviewed Pull Requests") [💻](https://github.com/ProctorU/squint/commits?author=king601 "Code") | [<img src="https://avatars2.githubusercontent.com/u/708692?v=3" width="100px;"/><br /><sub>Ryan T. Hosford</sub>](https://github.com/rthbound)<br />[💻](https://github.com/ProctorU/squint/commits?author=rthbound "Code") | [<img src="https://avatars2.githubusercontent.com/u/1785682?v=3" width="100px;"/><br /><sub>Matthew Jaeh</sub>](https://github.com/Jaehdawg)<br />[🎨](#design-Jaehdawg "Design") [👀](#review-Jaehdawg "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/3933204?v=3" width="100px;"/><br /><sub>Justin Licata</sub>](https://twitter.com/justinlicata)<br />[💻](https://github.com/ProctorU/squint/commits?author=licatajustin "Code") [🎨](#design-licatajustin "Design") [📖](https://github.com/ProctorU/squint/commits?author=licatajustin "Documentation") [👀](#review-licatajustin "Reviewed Pull Requests") | [<img src="https://avatars3.githubusercontent.com/u/24704300?v=4" width="100px;"/><br /><sub>Kyle Miracle</sub>](https://github.com/kmiracle86)<br />[🐛](https://github.com/ProctorU/squint/issues?q=author%3Akmiracle86 "Bug reports") [👀](#review-kmiracle86 "Reviewed Pull Requests") | [<img src="https://avatars2.githubusercontent.com/u/97011?v=3" width="100px;"/><br /><sub>David H. Wilkins</sub>](http://conecuh.com)<br />[💬](#question-dwilkins "Answering Questions") [🐛](https://github.com/ProctorU/squint/issues?q=author%3Adwilkins "Bug reports") [💻](https://github.com/ProctorU/squint/commits?author=dwilkins "Code") [🎨](#design-dwilkins "Design") [📖](https://github.com/ProctorU/squint/commits?author=dwilkins "Documentation") [💡](#example-dwilkins "Examples") [👀](#review-dwilkins "Reviewed Pull Requests") [⚠️](https://github.com/ProctorU/squint/commits?author=dwilkins "Tests") |
162
162
  | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
163
- | [<img src="https://avatars3.githubusercontent.com/u/19173815?v=3" width="100px;"/><br /><sub>Jay Wright</sub>](https://github.com/TheJayWright)<br />[👀](#review-TheJayWright "Reviewed Pull Requests") |
163
+ | [<img src="https://avatars3.githubusercontent.com/u/19173815?v=3" width="100px;"/><br /><sub>Jay Wright</sub>](https://github.com/TheJayWright)<br />[👀](#review-TheJayWright "Reviewed Pull Requests") | [<img src="https://avatars1.githubusercontent.com/u/4067?s=460&u=cb404cc0f1737c2fc53411e300cc8e158ef29295&v=4" width="100px;"/><br /><sub>James Cook</sub>](https://github.com/jamescook)<br />[💻](https://github.com/ProctorU/squint/commits?author=jamescook "Code") [⚠️](https://github.com/ProctorU/squint/commits?author=jamescook "Tests") [👀](#review-jamescook "Reviewed Pull Requests") |
164
164
  <!-- ALL-CONTRIBUTORS-LIST:END -->
165
165
 
166
166
  This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
@@ -11,4 +11,6 @@ class Post < ActiveRecord::Base
11
11
  store_attribute :storext_hstore_attributes, :hstore_friend_count, Integer, default: 0
12
12
  store_attribute :storext_hstore_attributes, :hstore_is_awesome, Integer, default: false
13
13
  store_attribute :storext_hstore_attributes, :hstore_is_present, Integer, default: nil
14
+
15
+ store_attribute :settings, :zip_code, String, default: '90210'
14
16
  end
@@ -0,0 +1,6 @@
1
+ class User < ActiveRecord::Base
2
+ include Storext.model
3
+ include Squint
4
+
5
+ store_attribute :settings, :zip_code, String, default: '90210'
6
+ end
@@ -0,0 +1,9 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.hstore :settings
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ class AddSettingsToPosts < ActiveRecord::Migration
2
+ def change
3
+ change_table :posts do |t|
4
+ t.jsonb :settings
5
+ end
6
+ end
7
+ end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  # This file is auto-generated from the current state of the database. Instead
3
2
  # of editing this file, please use the migrations feature of Active Record to
4
3
  # incrementally modify your database, and then regenerate this schema definition.
@@ -11,7 +10,7 @@
11
10
  #
12
11
  # It's strongly recommended that you check this file into your version control system.
13
12
 
14
- ActiveRecord::Schema.define(version: 20170512185941) do
13
+ ActiveRecord::Schema.define(version: 20200318185943) do
15
14
 
16
15
  # These are extensions that must be enabled in order to support this database
17
16
  enable_extension "plpgsql"
@@ -26,11 +25,17 @@ ActiveRecord::Schema.define(version: 20170512185941) do
26
25
  t.hstore "storext_hstore_attributes"
27
26
  t.datetime "created_at", null: false
28
27
  t.datetime "updated_at", null: false
28
+ t.jsonb "settings"
29
+ t.index ["properties"], name: "index_posts_on_properties", using: :gin
30
+ t.index ["request_info"], name: "index_posts_on_request_info", using: :gin
31
+ t.index ["storext_hstore_attributes"], name: "index_posts_on_storext_hstore_attributes", using: :gin
32
+ t.index ["storext_jsonb_attributes"], name: "index_posts_on_storext_jsonb_attributes", using: :gin
29
33
  end
30
34
 
31
- add_index "posts", ["properties"], name: "index_posts_on_properties", using: :gin
32
- add_index "posts", ["request_info"], name: "index_posts_on_request_info", using: :gin
33
- add_index "posts", ["storext_hstore_attributes"], name: "index_posts_on_storext_hstore_attributes", using: :gin
34
- add_index "posts", ["storext_jsonb_attributes"], name: "index_posts_on_storext_jsonb_attributes", using: :gin
35
+ create_table "users", force: :cascade do |t|
36
+ t.hstore "settings"
37
+ t.datetime "created_at", null: false
38
+ t.datetime "updated_at", null: false
39
+ end
35
40
 
36
41
  end
@@ -0,0 +1,6 @@
1
+ class User < ActiveRecord::Base
2
+ include Storext.model
3
+ include Squint
4
+
5
+ store_attribute :settings, :zip_code, String, default: '90210'
6
+ end
@@ -132,4 +132,9 @@ class SquintTest < ActiveSupport::TestCase
132
132
  created_at: '2015-01-01')
133
133
  end
134
134
  end
135
+
136
+ test 'HASH_DATA_COLUMNS is not shared between models' do
137
+ assert_equal('hstore', User::HASH_DATA_COLUMNS[:settings])
138
+ assert_equal('jsonb' , Post::HASH_DATA_COLUMNS[:settings])
139
+ end
135
140
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David H. Wilkins
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-12-07 00:00:00.000000000 Z
12
+ date: 2020-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 4.2.8
20
+ version: 5.1.6.2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 4.2.8
27
+ version: 5.1.6.2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: pg
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -69,7 +69,9 @@ files:
69
69
  - lib/squint/version.rb
70
70
  - readme.md
71
71
  - test/dummy/Rakefile
72
+ - test/dummy/app/assets/config/manifest.js
72
73
  - test/dummy/app/models/post.rb
74
+ - test/dummy/app/models/user.rb
73
75
  - test/dummy/config.ru
74
76
  - test/dummy/config/application.rb
75
77
  - test/dummy/config/boot.rb
@@ -77,8 +79,11 @@ files:
77
79
  - test/dummy/config/environment.rb
78
80
  - test/dummy/config/environments/test.rb
79
81
  - test/dummy/db/migrate/20170512185941_create_posts.rb
82
+ - test/dummy/db/migrate/20200318185942_create_users.rb
83
+ - test/dummy/db/migrate/20200318185943_add_settings_to_posts.rb
80
84
  - test/dummy/db/schema.rb
81
85
  - test/dummy/test/fixtures/posts.yml
86
+ - test/dummy/user.rb
82
87
  - test/squint_test.rb
83
88
  - test/test_helper.rb
84
89
  homepage: https://github.com/ProctorU/squint
@@ -100,22 +105,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
105
  - !ruby/object:Gem::Version
101
106
  version: '0'
102
107
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 2.7.6
108
+ rubygems_version: 3.0.8
105
109
  signing_key:
106
110
  specification_version: 4
107
111
  summary: Search PostgreSQL jsonb and hstore columns
108
112
  test_files:
113
+ - test/test_helper.rb
114
+ - test/dummy/Rakefile
115
+ - test/dummy/app/models/user.rb
109
116
  - test/dummy/app/models/post.rb
117
+ - test/dummy/app/assets/config/manifest.js
118
+ - test/dummy/user.rb
110
119
  - test/dummy/test/fixtures/posts.yml
111
120
  - test/dummy/config/environments/test.rb
112
- - test/dummy/config/environment.rb
113
121
  - test/dummy/config/application.rb
114
- - test/dummy/config/database.yml
115
122
  - test/dummy/config/boot.rb
123
+ - test/dummy/config/environment.rb
124
+ - test/dummy/config/database.yml
116
125
  - test/dummy/config.ru
117
- - test/dummy/Rakefile
118
126
  - test/dummy/db/schema.rb
127
+ - test/dummy/db/migrate/20200318185943_add_settings_to_posts.rb
119
128
  - test/dummy/db/migrate/20170512185941_create_posts.rb
129
+ - test/dummy/db/migrate/20200318185942_create_users.rb
120
130
  - test/squint_test.rb
121
- - test/test_helper.rb