arel-extensions 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +7 -7
- data/Gemfile +4 -0
- data/Gemfile.lock +55 -0
- data/Rakefile +14 -0
- data/arel-extensions.gemspec +8 -2
- data/lib/arel/extensions.rb +2 -0
- data/lib/arel/nodes/ts_query.rb +1 -1
- data/lib/arel/nodes/ts_rank.rb +14 -0
- data/lib/arel/nodes/ts_rank_cd.rb +14 -0
- data/lib/arel/nodes/ts_vector.rb +1 -1
- data/lib/arel/visitors/postgresql_extensions.rb +18 -0
- data/test/database.rb +40 -0
- data/test/test_helper.rb +131 -0
- data/test/ts_test.rb +136 -0
- metadata +85 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7760e9c8da3eca620a0c390b8767b4e1dd37be5e7612debf58f0bb284e8809ca
|
4
|
+
data.tar.gz: ba383da2aecf077b8b91c8e3ed29f3724093fc0c8e15329b96b9b6b077c67ca6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6a5d3844c8d1f2d24b6f6c7306f8f2338ebfba347df06108539e09771ea10d3fc453f47b976cd05ffda0addda6ce57fbaeebdb96b0671efa10a6518fbc14627
|
7
|
+
data.tar.gz: ff44a1804d9691fa8ffd445b5115d00c6e0b42adf403681aeb741bb71bae9651dbf1b2b97c70035388afb1ae56771c963d9fb8bc11a718d0289869d29d6627f2
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.DS_Store
|
data/.travis.yml
CHANGED
@@ -5,17 +5,17 @@ cache:
|
|
5
5
|
bundler: true
|
6
6
|
|
7
7
|
rvm:
|
8
|
-
- 2.3.4
|
9
8
|
- 2.4.1
|
9
|
+
- 2.5.1
|
10
10
|
|
11
11
|
env:
|
12
12
|
matrix:
|
13
|
-
- RAILS_VERSION=v5.
|
14
|
-
- RAILS_VERSION=v5.
|
15
|
-
- RAILS_VERSION=v5.
|
16
|
-
- RAILS_VERSION=v5.
|
17
|
-
- RAILS_VERSION=v5.
|
18
|
-
- RAILS_VERSION=v5.
|
13
|
+
- RAILS_VERSION=v5.2.0 GEM=ar:mysql2
|
14
|
+
- RAILS_VERSION=v5.2.0 GEM=ar:sqlite3
|
15
|
+
- RAILS_VERSION=v5.2.0 GEM=ar:postgresql
|
16
|
+
- RAILS_VERSION=v5.2.1 GEM=ar:mysql2
|
17
|
+
- RAILS_VERSION=v5.2.1 GEM=ar:sqlite3
|
18
|
+
- RAILS_VERSION=v5.2.1 GEM=ar:postgresql
|
19
19
|
|
20
20
|
addons:
|
21
21
|
postgresql: "9.4"
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
arel-extensions (1.6.0)
|
5
|
+
arel (>= 9.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (5.2.1)
|
11
|
+
activesupport (= 5.2.1)
|
12
|
+
activerecord (5.2.1)
|
13
|
+
activemodel (= 5.2.1)
|
14
|
+
activesupport (= 5.2.1)
|
15
|
+
arel (>= 9.0)
|
16
|
+
activesupport (5.2.1)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (>= 0.7, < 2)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
tzinfo (~> 1.1)
|
21
|
+
ansi (1.5.0)
|
22
|
+
arel (9.0.0)
|
23
|
+
builder (3.2.3)
|
24
|
+
concurrent-ruby (1.0.5)
|
25
|
+
i18n (1.1.1)
|
26
|
+
concurrent-ruby (~> 1.0)
|
27
|
+
minitest (5.11.3)
|
28
|
+
minitest-reporters (1.3.5)
|
29
|
+
ansi
|
30
|
+
builder
|
31
|
+
minitest (>= 5.0)
|
32
|
+
ruby-progressbar
|
33
|
+
pg (1.1.3)
|
34
|
+
rake (12.3.1)
|
35
|
+
rgeo (1.0.0)
|
36
|
+
ruby-progressbar (1.10.0)
|
37
|
+
thread_safe (0.3.6)
|
38
|
+
tzinfo (1.2.5)
|
39
|
+
thread_safe (~> 0.1)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
activerecord
|
46
|
+
arel-extensions!
|
47
|
+
bundler
|
48
|
+
minitest
|
49
|
+
minitest-reporters
|
50
|
+
pg
|
51
|
+
rake
|
52
|
+
rgeo
|
53
|
+
|
54
|
+
BUNDLED WITH
|
55
|
+
1.16.0
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
Bundler.require(:development)
|
4
|
+
|
5
|
+
require 'fileutils'
|
6
|
+
require "rake/testtask"
|
7
|
+
|
8
|
+
# Test Task
|
9
|
+
Rake::TestTask.new do |t|
|
10
|
+
t.libs << 'lib' << 'test'
|
11
|
+
t.test_files = FileList['test/**/*_test.rb']
|
12
|
+
# t.warning = true
|
13
|
+
# t.verbose = true
|
14
|
+
end
|
data/arel-extensions.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'arel-extensions'
|
3
|
-
gem.version = '1.
|
3
|
+
gem.version = '1.7.0'
|
4
4
|
|
5
5
|
gem.authors = ["Jon Bracy"]
|
6
6
|
gem.email = ["jonbracy@gmail.com"]
|
@@ -14,6 +14,12 @@ Gem::Specification.new do |gem|
|
|
14
14
|
|
15
15
|
gem.add_dependency 'arel', '>= 9.0.0'
|
16
16
|
|
17
|
-
gem.add_development_dependency
|
17
|
+
gem.add_development_dependency "bundler"
|
18
|
+
gem.add_development_dependency "rake"
|
18
19
|
gem.add_development_dependency 'minitest'
|
20
|
+
gem.add_development_dependency 'minitest-reporters'
|
21
|
+
gem.add_development_dependency 'pg'
|
22
|
+
gem.add_development_dependency 'rgeo'
|
23
|
+
gem.add_development_dependency 'activerecord'
|
24
|
+
|
19
25
|
end
|
data/lib/arel/extensions.rb
CHANGED
@@ -20,6 +20,8 @@ Arel::Attributes::Attribute.include(Arel::JSONPredications)
|
|
20
20
|
require File.expand_path('../nodes/ts_vector', __FILE__)
|
21
21
|
require File.expand_path('../nodes/ts_query', __FILE__)
|
22
22
|
require File.expand_path('../nodes/ts_match', __FILE__)
|
23
|
+
require File.expand_path('../nodes/ts_rank', __FILE__)
|
24
|
+
require File.expand_path('../nodes/ts_rank_cd', __FILE__)
|
23
25
|
require File.expand_path('../ts_predications', __FILE__)
|
24
26
|
Arel::Attributes::Attribute.include(Arel::TSPredications)
|
25
27
|
|
data/lib/arel/nodes/ts_query.rb
CHANGED
data/lib/arel/nodes/ts_vector.rb
CHANGED
@@ -119,6 +119,24 @@ module Arel
|
|
119
119
|
collector
|
120
120
|
end
|
121
121
|
|
122
|
+
def visit_Arel_Nodes_TSRank(o, collector)
|
123
|
+
collector << 'ts_rank('
|
124
|
+
visit(o.tsvector, collector)
|
125
|
+
collector << ', '
|
126
|
+
visit(o.tsquery, collector)
|
127
|
+
collector << ')'
|
128
|
+
collector
|
129
|
+
end
|
130
|
+
|
131
|
+
def visit_Arel_Nodes_TSRankCD(o, collector)
|
132
|
+
collector << 'ts_rank_cd('
|
133
|
+
visit(o.tsvector, collector)
|
134
|
+
collector << ', '
|
135
|
+
visit(o.tsquery, collector)
|
136
|
+
collector << ')'
|
137
|
+
collector
|
138
|
+
end
|
139
|
+
|
122
140
|
def visit_Arel_Nodes_HexEncodedBinary(o, collector)
|
123
141
|
collector << "E'\\\\x"
|
124
142
|
collector << o.expr
|
data/test/database.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
task = ActiveRecord::Tasks::PostgreSQLDatabaseTasks.new({
|
2
|
+
'adapter' => 'postgresql',
|
3
|
+
'database' => "arel-extensions-test"
|
4
|
+
})
|
5
|
+
task.drop
|
6
|
+
task.create
|
7
|
+
|
8
|
+
ActiveRecord::Base.establish_connection({
|
9
|
+
adapter: "postgresql",
|
10
|
+
database: "arel-extensions-test",
|
11
|
+
encoding: "utf8"
|
12
|
+
})
|
13
|
+
|
14
|
+
ActiveRecord::Migration.suppress_messages do
|
15
|
+
ActiveRecord::Schema.define do
|
16
|
+
|
17
|
+
create_table "addresses", force: :cascade do |t|
|
18
|
+
t.integer "name"
|
19
|
+
t.integer "property_id"
|
20
|
+
end
|
21
|
+
|
22
|
+
create_table "properties", force: :cascade do |t|
|
23
|
+
t.string "name", limit: 255
|
24
|
+
t.tsvector 'vector_col'
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Address < ActiveRecord::Base
|
31
|
+
|
32
|
+
belongs_to :property
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
class Property < ActiveRecord::Base
|
37
|
+
|
38
|
+
has_many :addresses
|
39
|
+
|
40
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
# To make testing/debugging easier, test within this source tree versus an
|
2
|
+
# installed gem
|
3
|
+
$LOAD_PATH << File.expand_path('../lib', __FILE__)
|
4
|
+
|
5
|
+
# require 'simplecov'
|
6
|
+
# SimpleCov.start do
|
7
|
+
# add_group 'lib', 'sunstone/lib'
|
8
|
+
# add_group 'ext', 'sunstone/ext'
|
9
|
+
# end
|
10
|
+
|
11
|
+
require 'rgeo'
|
12
|
+
require "minitest/autorun"
|
13
|
+
require 'minitest/unit'
|
14
|
+
require 'minitest/reporters'
|
15
|
+
# require 'webmock/minitest'
|
16
|
+
# require 'mocha/minitest'
|
17
|
+
require 'active_record'
|
18
|
+
require 'arel/extensions'
|
19
|
+
|
20
|
+
# Setup the test db
|
21
|
+
ActiveSupport.test_order = :random
|
22
|
+
require File.expand_path('../database', __FILE__)
|
23
|
+
|
24
|
+
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
25
|
+
|
26
|
+
$debugging = false
|
27
|
+
|
28
|
+
# File 'lib/active_support/testing/declarative.rb', somewhere in rails....
|
29
|
+
class ActiveSupport::TestCase
|
30
|
+
# include WebMock::API
|
31
|
+
|
32
|
+
# File 'lib/active_support/testing/declarative.rb'
|
33
|
+
def self.test(name, &block)
|
34
|
+
test_name = "test_#{name.gsub(/\s+/, '_')}".to_sym
|
35
|
+
defined = method_defined? test_name
|
36
|
+
raise "#{test_name} is already defined in #{self}" if defined
|
37
|
+
if block_given?
|
38
|
+
define_method(test_name, &block)
|
39
|
+
else
|
40
|
+
define_method(test_name) do
|
41
|
+
skip "No implementation provided for #{name}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def webmock(method, path, query=nil)
|
47
|
+
query = deep_transform_query(query) if query
|
48
|
+
|
49
|
+
stub_request(method, /^#{ActiveRecord::Base.connection.instance_variable_get(:@connection).url}/).with do |req|
|
50
|
+
if query
|
51
|
+
req&.uri&.path == path && req.uri.query && unpack(req.uri.query.sub(/=true$/, '')) == query
|
52
|
+
else
|
53
|
+
req&.uri&.path == path && req.uri.query.nil?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def debug
|
59
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
60
|
+
$debugging = true
|
61
|
+
yield
|
62
|
+
ensure
|
63
|
+
ActiveRecord::Base.logger = nil
|
64
|
+
$debugging = false
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
class SQLLogger
|
69
|
+
class << self
|
70
|
+
attr_accessor :ignored_sql, :log, :log_all
|
71
|
+
def clear_log; self.log = []; self.log_all = []; end
|
72
|
+
end
|
73
|
+
|
74
|
+
self.clear_log
|
75
|
+
|
76
|
+
self.ignored_sql = [/^PRAGMA/i, /^SELECT currval/i, /^SELECT CAST/i, /^SELECT @@IDENTITY/i, /^SELECT @@ROWCOUNT/i, /^SAVEPOINT/i, /^ROLLBACK TO SAVEPOINT/i, /^RELEASE SAVEPOINT/i, /^SHOW max_identifier_length/i, /^BEGIN/i, /^COMMIT/i]
|
77
|
+
|
78
|
+
# FIXME: this needs to be refactored so specific database can add their own
|
79
|
+
# ignored SQL, or better yet, use a different notification for the queries
|
80
|
+
# instead examining the SQL content.
|
81
|
+
oracle_ignored = [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im, /^\s*select .* from all_constraints/im, /^\s*select .* from all_tab_cols/im]
|
82
|
+
mysql_ignored = [/^SHOW FULL TABLES/i, /^SHOW FULL FIELDS/, /^SHOW CREATE TABLE /i, /^SHOW VARIABLES /, /^\s*SELECT (?:column_name|table_name)\b.*\bFROM information_schema\.(?:key_column_usage|tables)\b/im]
|
83
|
+
postgresql_ignored = [/^\s*select\b.*\bfrom\b.*pg_namespace\b/im, /^\s*select tablename\b.*from pg_tables\b/im, /^\s*select\b.*\battname\b.*\bfrom\b.*\bpg_attribute\b/im, /^SHOW search_path/i]
|
84
|
+
sqlite3_ignored = [/^\s*SELECT name\b.*\bFROM sqlite_master/im, /^\s*SELECT sql\b.*\bFROM sqlite_master/im]
|
85
|
+
|
86
|
+
[oracle_ignored, mysql_ignored, postgresql_ignored, sqlite3_ignored].each do |db_ignored_sql|
|
87
|
+
ignored_sql.concat db_ignored_sql
|
88
|
+
end
|
89
|
+
|
90
|
+
attr_reader :ignore
|
91
|
+
|
92
|
+
def initialize(ignore = Regexp.union(self.class.ignored_sql))
|
93
|
+
@ignore = ignore
|
94
|
+
end
|
95
|
+
|
96
|
+
def call(name, start, finish, message_id, values)
|
97
|
+
sql = values[:sql]
|
98
|
+
|
99
|
+
# FIXME: this seems bad. we should probably have a better way to indicate
|
100
|
+
# the query was cached
|
101
|
+
return if 'CACHE' == values[:name]
|
102
|
+
|
103
|
+
self.class.log_all << sql
|
104
|
+
unless ignore =~ sql
|
105
|
+
if $debugging
|
106
|
+
puts caller.select { |l| l.starts_with?(File.expand_path('../../lib', __FILE__)) }
|
107
|
+
puts "\n\n"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
self.class.log << sql unless ignore =~ sql
|
111
|
+
end
|
112
|
+
end
|
113
|
+
ActiveSupport::Notifications.subscribe('sql.active_record', SQLLogger.new)
|
114
|
+
|
115
|
+
# test/unit backwards compatibility methods
|
116
|
+
alias :assert_raise :assert_raises
|
117
|
+
alias :assert_not_empty :refute_empty
|
118
|
+
alias :assert_not_equal :refute_equal
|
119
|
+
alias :assert_not_in_delta :refute_in_delta
|
120
|
+
alias :assert_not_in_epsilon :refute_in_epsilon
|
121
|
+
alias :assert_not_includes :refute_includes
|
122
|
+
alias :assert_not_instance_of :refute_instance_of
|
123
|
+
alias :assert_not_kind_of :refute_kind_of
|
124
|
+
alias :assert_no_match :refute_match
|
125
|
+
alias :assert_not_nil :refute_nil
|
126
|
+
alias :assert_not_operator :refute_operator
|
127
|
+
alias :assert_not_predicate :refute_predicate
|
128
|
+
alias :assert_not_respond_to :refute_respond_to
|
129
|
+
alias :assert_not_same :refute_same
|
130
|
+
|
131
|
+
end
|
data/test/ts_test.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TSTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test 'tsquery(query)' do
|
6
|
+
query = Property.where( Arel::Nodes::TSQuery.new('query') )
|
7
|
+
|
8
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
9
|
+
SELECT "properties".* FROM "properties"
|
10
|
+
WHERE to_tsquery('query')
|
11
|
+
SQL
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'tsquery(query, language: lang)' do
|
15
|
+
query = Property.where( Arel::Nodes::TSQuery.new('query', language: 'lang') )
|
16
|
+
|
17
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
18
|
+
SELECT "properties".* FROM "properties"
|
19
|
+
WHERE to_tsquery('lang', 'query')
|
20
|
+
SQL
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'tsvector(attribute)' do
|
24
|
+
query = Property.where( Arel::Nodes::TSVector.new(Property.arel_table[:name]) )
|
25
|
+
|
26
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
27
|
+
SELECT "properties".* FROM "properties"
|
28
|
+
WHERE to_tsvector("properties"."name")
|
29
|
+
SQL
|
30
|
+
end
|
31
|
+
|
32
|
+
test 'tsvector(text)' do
|
33
|
+
query = Property.where( Arel::Nodes::TSVector.new(
|
34
|
+
Arel::Nodes::Quoted.new("my data O'Malley")
|
35
|
+
))
|
36
|
+
|
37
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
38
|
+
SELECT "properties".* FROM "properties"
|
39
|
+
WHERE to_tsvector('my data O''Malley')
|
40
|
+
SQL
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'tsvector(attribute, language: lang)' do
|
44
|
+
query = Property.where( Arel::Nodes::TSVector.new(Property.arel_table[:name], language: 'lang') )
|
45
|
+
|
46
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
47
|
+
SELECT "properties".* FROM "properties"
|
48
|
+
WHERE to_tsvector('lang', "properties"."name")
|
49
|
+
SQL
|
50
|
+
end
|
51
|
+
|
52
|
+
test 'ts_match(attrbute, tsquery)' do
|
53
|
+
query = Property.where(
|
54
|
+
Arel::Nodes::TSMatch.new(
|
55
|
+
Property.arel_table[:name],
|
56
|
+
Arel::Nodes::TSQuery.new('query')
|
57
|
+
)
|
58
|
+
)
|
59
|
+
|
60
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
61
|
+
SELECT "properties".* FROM "properties"
|
62
|
+
WHERE "properties"."name" @@ to_tsquery('query')
|
63
|
+
SQL
|
64
|
+
end
|
65
|
+
|
66
|
+
test 'ts_match(tsvector, tsquery)' do
|
67
|
+
query = Property.where(
|
68
|
+
Arel::Nodes::TSMatch.new(
|
69
|
+
Arel::Nodes::TSVector.new(Property.arel_table[:name]),
|
70
|
+
Arel::Nodes::TSQuery.new('query')
|
71
|
+
)
|
72
|
+
)
|
73
|
+
|
74
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
75
|
+
SELECT "properties".* FROM "properties"
|
76
|
+
WHERE to_tsvector("properties"."name") @@ to_tsquery('query')
|
77
|
+
SQL
|
78
|
+
end
|
79
|
+
|
80
|
+
test 'ts_rank(attribute, tsquery)' do
|
81
|
+
query = Property.where(
|
82
|
+
Arel::Nodes::TSRank.new(
|
83
|
+
Property.arel_table[:name],
|
84
|
+
Arel::Nodes::TSQuery.new('query')
|
85
|
+
)
|
86
|
+
)
|
87
|
+
|
88
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
89
|
+
SELECT "properties".* FROM "properties"
|
90
|
+
WHERE ts_rank("properties"."name", to_tsquery('query'))
|
91
|
+
SQL
|
92
|
+
end
|
93
|
+
|
94
|
+
test 'ts_rank(tsvector, tsquery)' do
|
95
|
+
query = Property.where(
|
96
|
+
Arel::Nodes::TSRank.new(
|
97
|
+
Arel::Nodes::TSVector.new(Property.arel_table[:name]),
|
98
|
+
Arel::Nodes::TSQuery.new('query')
|
99
|
+
)
|
100
|
+
)
|
101
|
+
|
102
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
103
|
+
SELECT "properties".* FROM "properties"
|
104
|
+
WHERE ts_rank(to_tsvector("properties"."name"), to_tsquery('query'))
|
105
|
+
SQL
|
106
|
+
end
|
107
|
+
|
108
|
+
test 'ts_rank_cd(attribute, tsquery)' do
|
109
|
+
query = Property.where(
|
110
|
+
Arel::Nodes::TSRankCD.new(
|
111
|
+
Property.arel_table[:name],
|
112
|
+
Arel::Nodes::TSQuery.new('query')
|
113
|
+
)
|
114
|
+
)
|
115
|
+
|
116
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
117
|
+
SELECT "properties".* FROM "properties"
|
118
|
+
WHERE ts_rank_cd("properties"."name", to_tsquery('query'))
|
119
|
+
SQL
|
120
|
+
end
|
121
|
+
|
122
|
+
test 'ts_rank_cd(tsvector, tsquery)' do
|
123
|
+
query = Property.where(
|
124
|
+
Arel::Nodes::TSRankCD.new(
|
125
|
+
Arel::Nodes::TSVector.new(Property.arel_table[:name]),
|
126
|
+
Arel::Nodes::TSQuery.new('query')
|
127
|
+
)
|
128
|
+
)
|
129
|
+
|
130
|
+
assert_equal(<<~SQL.gsub(/( +|\n)/, ' ').strip, query.to_sql)
|
131
|
+
SELECT "properties".* FROM "properties"
|
132
|
+
WHERE ts_rank_cd(to_tsvector("properties"."name"), to_tsquery('query'))
|
133
|
+
SQL
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arel-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Bracy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: arel
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 9.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +66,62 @@ dependencies:
|
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest-reporters
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pg
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rgeo
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activerecord
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
55
125
|
description:
|
56
126
|
email:
|
57
127
|
- jonbracy@gmail.com
|
@@ -59,9 +129,13 @@ executables: []
|
|
59
129
|
extensions: []
|
60
130
|
extra_rdoc_files: []
|
61
131
|
files:
|
132
|
+
- ".gitignore"
|
62
133
|
- ".travis.yml"
|
134
|
+
- Gemfile
|
135
|
+
- Gemfile.lock
|
63
136
|
- LICENSE
|
64
137
|
- README.md
|
138
|
+
- Rakefile
|
65
139
|
- arel-extensions.gemspec
|
66
140
|
- lib/active_record/query_methods.rb
|
67
141
|
- lib/arel/array_predications.rb
|
@@ -80,11 +154,16 @@ files:
|
|
80
154
|
- lib/arel/nodes/overlaps.rb
|
81
155
|
- lib/arel/nodes/ts_match.rb
|
82
156
|
- lib/arel/nodes/ts_query.rb
|
157
|
+
- lib/arel/nodes/ts_rank.rb
|
158
|
+
- lib/arel/nodes/ts_rank_cd.rb
|
83
159
|
- lib/arel/nodes/ts_vector.rb
|
84
160
|
- lib/arel/nodes/within.rb
|
85
161
|
- lib/arel/ts_predications.rb
|
86
162
|
- lib/arel/visitors/postgresql_extensions.rb
|
87
163
|
- lib/arel/visitors/sunstone_extensions.rb
|
164
|
+
- test/database.rb
|
165
|
+
- test/test_helper.rb
|
166
|
+
- test/ts_test.rb
|
88
167
|
homepage: https://github.com/malomalo/arel-extensions
|
89
168
|
licenses:
|
90
169
|
- MIT
|
@@ -109,4 +188,7 @@ rubygems_version: 2.7.4
|
|
109
188
|
signing_key:
|
110
189
|
specification_version: 4
|
111
190
|
summary: Adds support for missing SQL operators and functions to Arel
|
112
|
-
test_files:
|
191
|
+
test_files:
|
192
|
+
- test/database.rb
|
193
|
+
- test/test_helper.rb
|
194
|
+
- test/ts_test.rb
|