activerecord-full_text_search 0.2.0 → 0.3.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5bccc63fac75881da6efbc80e1281588f0091d6e227d11fd8335623366f720dd
|
|
4
|
+
data.tar.gz: 36440ad1275656da894a59ad1afb8f908e4fafb2070232f302161a2994a756b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d75a6e9c06fd2e609ebf27b4a041fff217b1f3207cbabab342da4011a06c7293bc84888483b063c9618b86fd6eb86af6ad2e91f760807a15a10450246657758
|
|
7
|
+
data.tar.gz: 7ab9fbaef688c03932c72661e60f74e9b4593bf5388f0b5a8727386a4408e16fcaf750f1603b609a67dce2f8b54314bad81f13b634de020e2cd6fe504ba5afec
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-06-02
|
|
11
|
+
|
|
12
|
+
- Add Rails 8.0 & 8.1 as known versions
|
|
13
|
+
- Sort functions and triggers
|
|
14
|
+
|
|
10
15
|
## [0.2.0] - 2024-12-03
|
|
11
16
|
|
|
12
17
|
- Add basic support for TRIGGERS
|
|
@@ -15,15 +15,44 @@ module ActiveRecord
|
|
|
15
15
|
def functions
|
|
16
16
|
# List of functions in the current schema with their argument types, return type, language, immutability, and body.
|
|
17
17
|
# List only functions that don't depend on extensions.
|
|
18
|
+
# Functions are ordered by dependency depth (via pg_depend) so that dependencies come first.
|
|
18
19
|
res = exec_query(<<-SQL.strip_heredoc, "SCHEMA")
|
|
20
|
+
WITH RECURSIVE
|
|
21
|
+
func_deps AS (
|
|
22
|
+
SELECT p.oid AS func_oid, dep_p.oid AS dep_func_oid
|
|
23
|
+
FROM pg_catalog.pg_proc p
|
|
24
|
+
JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
|
|
25
|
+
JOIN pg_catalog.pg_depend fd ON fd.objid = p.oid AND fd.deptype = 'n'
|
|
26
|
+
JOIN pg_catalog.pg_proc dep_p ON dep_p.oid = fd.refobjid
|
|
27
|
+
JOIN pg_catalog.pg_namespace dep_n ON dep_n.oid = dep_p.pronamespace
|
|
28
|
+
WHERE n.nspname = ANY (current_schemas(false))
|
|
29
|
+
AND dep_n.nspname = ANY (current_schemas(false))
|
|
30
|
+
AND p.oid != dep_p.oid
|
|
31
|
+
),
|
|
32
|
+
levels(oid, level) AS (
|
|
33
|
+
SELECT p.oid, 0
|
|
34
|
+
FROM pg_catalog.pg_proc p
|
|
35
|
+
JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
|
|
36
|
+
WHERE n.nspname = ANY (current_schemas(false))
|
|
37
|
+
AND p.oid NOT IN (SELECT func_oid FROM func_deps)
|
|
38
|
+
UNION ALL
|
|
39
|
+
SELECT fd.func_oid, l.level + 1
|
|
40
|
+
FROM func_deps fd
|
|
41
|
+
JOIN levels l ON l.oid = fd.dep_func_oid
|
|
42
|
+
),
|
|
43
|
+
max_levels AS (
|
|
44
|
+
SELECT oid, MAX(level) AS level FROM levels GROUP BY oid
|
|
45
|
+
)
|
|
19
46
|
SELECT proname, pg_catalog.pg_get_function_arguments(p.oid) AS argtypes, pg_catalog.pg_get_function_result(p.oid) AS rettype, lanname, provolatile, prosrc
|
|
20
47
|
FROM pg_catalog.pg_proc p
|
|
21
|
-
JOIN pg_catalog.pg_namespace n ON n.oid = pronamespace
|
|
22
|
-
JOIN pg_catalog.pg_language l ON l.oid = prolang
|
|
48
|
+
JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
|
|
49
|
+
JOIN pg_catalog.pg_language l ON l.oid = p.prolang
|
|
23
50
|
LEFT JOIN pg_catalog.pg_depend d ON d.objid = p.oid AND d.deptype = 'e'
|
|
24
51
|
LEFT JOIN pg_catalog.pg_extension e ON e.oid = d.refobjid
|
|
52
|
+
JOIN max_levels ml ON ml.oid = p.oid
|
|
25
53
|
WHERE n.nspname = ANY (current_schemas(false))
|
|
26
|
-
AND e.extname IS NULL
|
|
54
|
+
AND e.extname IS NULL
|
|
55
|
+
ORDER BY ml.level, proname;
|
|
27
56
|
SQL
|
|
28
57
|
|
|
29
58
|
res.rows.each_with_object({}) do |(name, args, ret, lang, vol, src), memo|
|
|
@@ -49,7 +78,7 @@ module ActiveRecord
|
|
|
49
78
|
-- || (CASE WHEN (tgtype::int::bit(7) & b'0100000')::int = 0 THEN '' ELSE ' truncate' END)
|
|
50
79
|
AS tg_ops,
|
|
51
80
|
CASE WHEN (tgtype::int::bit(7) & b'0000001')::int = 0 THEN 'statement' ELSE 'row' END as tg_foreach,
|
|
52
|
-
|
|
81
|
+
pg_get_triggerdef(t.oid, true) AS tg_definition,
|
|
53
82
|
tgdeferrable,
|
|
54
83
|
tginitdeferred
|
|
55
84
|
FROM pg_catalog.pg_trigger t
|
|
@@ -60,11 +89,13 @@ module ActiveRecord
|
|
|
60
89
|
LEFT JOIN pg_catalog.pg_extension e ON e.oid = d.refobjid
|
|
61
90
|
WHERE n.nspname = ANY (current_schemas(false))
|
|
62
91
|
AND tgisinternal = FALSE
|
|
63
|
-
AND e.extname IS NULL
|
|
92
|
+
AND e.extname IS NULL
|
|
93
|
+
ORDER BY c.relname, tgname;
|
|
64
94
|
SQL
|
|
65
95
|
|
|
66
|
-
res.rows.each_with_object({}) do |(name, table, function, timing, ops, for_each,
|
|
96
|
+
res.rows.each_with_object({}) do |(name, table, function, timing, ops, for_each, definition, deferrable, initially_deferred), memo|
|
|
67
97
|
attributes = {table: table, function: function, for_each: for_each.to_sym}
|
|
98
|
+
condition = extract_trigger_condition(definition)
|
|
68
99
|
attributes[:when] = condition if condition.present?
|
|
69
100
|
attributes[timing.to_sym] = ops.strip.split(/\s+/).map(&:to_sym)
|
|
70
101
|
attributes[:deferrable] = initially_deferred ? :initially_deferred : true if deferrable
|
|
@@ -150,6 +181,12 @@ module ActiveRecord
|
|
|
150
181
|
|
|
151
182
|
private
|
|
152
183
|
|
|
184
|
+
def extract_trigger_condition(definition)
|
|
185
|
+
return unless definition
|
|
186
|
+
|
|
187
|
+
definition[/\bWHEN\s*\((.*)\)\s+EXECUTE\s+FUNCTION\b/m, 1]
|
|
188
|
+
end
|
|
189
|
+
|
|
153
190
|
def options_to_hash(text)
|
|
154
191
|
text.split(/\s*,\s*/).map { |s| s.strip.split(/\s+=\s+/) }.to_h.transform_values { |v| v[1..-2] }.transform_keys(&:to_sym)
|
|
155
192
|
end
|
|
@@ -3,7 +3,15 @@ require "active_support/lazy_load_hooks"
|
|
|
3
3
|
|
|
4
4
|
module ActiveRecord
|
|
5
5
|
module FullTextSearch
|
|
6
|
-
KNOWN_VERSIONS = %w[7.2].map { |v| Gem::Version.new(v) }.freeze
|
|
6
|
+
KNOWN_VERSIONS = %w[7.2 8.0 8.1].map { |v| Gem::Version.new(v) }.freeze
|
|
7
|
+
|
|
8
|
+
# Maps a supported version to the directory containing its implementation.
|
|
9
|
+
# Versions that share an implementation point to the same directory.
|
|
10
|
+
VERSION_DIRECTORIES = {
|
|
11
|
+
Gem::Version.new("7.2") => "7.2",
|
|
12
|
+
Gem::Version.new("8.0") => "7.2",
|
|
13
|
+
Gem::Version.new("8.1") => "7.2",
|
|
14
|
+
}.freeze
|
|
7
15
|
|
|
8
16
|
class << self
|
|
9
17
|
attr_reader :enabled_version
|
|
@@ -39,7 +47,8 @@ module ActiveRecord
|
|
|
39
47
|
require "active_record/full_text_search/command_recorder"
|
|
40
48
|
require "active_record/full_text_search/schema_statements"
|
|
41
49
|
|
|
42
|
-
|
|
50
|
+
directory = VERSION_DIRECTORIES.fetch(enabled_version, enabled_version.to_s)
|
|
51
|
+
Dir[File.join(__dir__, "full_text_search", directory, "*.rb")].each { |file| require file }
|
|
43
52
|
monkeypatches.keys.each { |patch| monkeypatches.delete(patch).call }
|
|
44
53
|
end
|
|
45
54
|
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-full_text_search
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Codeur SAS
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: pg
|
|
@@ -85,7 +84,6 @@ metadata:
|
|
|
85
84
|
changelog_uri: https://github.com/codeur/activerecord-full_text_search/blob/master/CHANGELOG.md
|
|
86
85
|
pgp_keys_uri: https://keybase.io/codeur/pgp_keys.asc
|
|
87
86
|
signatures_uri: https://keybase.pub/codeur/gems/
|
|
88
|
-
post_install_message:
|
|
89
87
|
rdoc_options: []
|
|
90
88
|
require_paths:
|
|
91
89
|
- lib
|
|
@@ -100,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
100
98
|
- !ruby/object:Gem::Version
|
|
101
99
|
version: '0'
|
|
102
100
|
requirements: []
|
|
103
|
-
rubygems_version: 3.
|
|
104
|
-
signing_key:
|
|
101
|
+
rubygems_version: 3.6.9
|
|
105
102
|
specification_version: 4
|
|
106
103
|
summary: Integrate PostgreSQL's FTS configs with Rails
|
|
107
104
|
test_files: []
|