pg_objects 1.4.8 → 1.5.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +1 -1
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +13 -2
  5. data/CHANGELOG.md +78 -0
  6. data/Gemfile +2 -0
  7. data/Gemfile.lock +71 -54
  8. data/README.md +174 -3
  9. data/Rakefile +2 -0
  10. data/bin/benchmark +42 -7
  11. data/bin/console +1 -0
  12. data/lib/generators/pg_objects/install/install_generator.rb +2 -0
  13. data/lib/pg_objects/config.rb +53 -2
  14. data/lib/pg_objects/db_object.rb +6 -1
  15. data/lib/pg_objects/db_object_factory.rb +11 -3
  16. data/lib/pg_objects/logger.rb +34 -3
  17. data/lib/pg_objects/manager.rb +66 -15
  18. data/lib/pg_objects/parsed_object/aggregate.rb +9 -1
  19. data/lib/pg_objects/parsed_object/base.rb +38 -0
  20. data/lib/pg_objects/parsed_object/base_type.rb +17 -0
  21. data/lib/pg_objects/parsed_object/conversion.rb +9 -1
  22. data/lib/pg_objects/parsed_object/domain.rb +16 -0
  23. data/lib/pg_objects/parsed_object/enum_type.rb +16 -0
  24. data/lib/pg_objects/parsed_object/event_trigger.rb +3 -1
  25. data/lib/pg_objects/parsed_object/extension.rb +10 -0
  26. data/lib/pg_objects/parsed_object/function.rb +9 -1
  27. data/lib/pg_objects/parsed_object/index.rb +17 -0
  28. data/lib/pg_objects/parsed_object/materialized_view.rb +9 -1
  29. data/lib/pg_objects/parsed_object/operator.rb +9 -1
  30. data/lib/pg_objects/parsed_object/operator_class.rb +9 -1
  31. data/lib/pg_objects/parsed_object/policy.rb +10 -0
  32. data/lib/pg_objects/parsed_object/range_type.rb +16 -0
  33. data/lib/pg_objects/parsed_object/rule.rb +10 -0
  34. data/lib/pg_objects/parsed_object/sequence.rb +16 -0
  35. data/lib/pg_objects/parsed_object/table.rb +9 -1
  36. data/lib/pg_objects/parsed_object/text_search_parser.rb +9 -1
  37. data/lib/pg_objects/parsed_object/text_search_template.rb +9 -1
  38. data/lib/pg_objects/parsed_object/trigger.rb +3 -1
  39. data/lib/pg_objects/parsed_object/type.rb +9 -1
  40. data/lib/pg_objects/parsed_object/view.rb +9 -1
  41. data/lib/pg_objects/parsed_object.rb +11 -0
  42. data/lib/pg_objects/parsed_object_factory.rb +52 -90
  43. data/lib/pg_objects/parser.rb +28 -12
  44. data/lib/pg_objects/railtie.rb +2 -0
  45. data/lib/pg_objects/version.rb +3 -1
  46. data/lib/pg_objects/yaml_configurable.rb +25 -7
  47. data/lib/pg_objects.rb +54 -4
  48. data/lib/tasks/pg_objects_tasks.rake +33 -8
  49. data/pg_objects.gemspec +5 -3
  50. metadata +16 -20
  51. data/.github/copilot-instructions.md +0 -131
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.8
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Kiselyov
@@ -59,32 +59,18 @@ dependencies:
59
59
  version: '1'
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: dry-container
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - '='
65
- - !ruby/object:Gem::Version
66
- version: 0.11.0
67
- type: :runtime
68
- prerelease: false
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - '='
72
- - !ruby/object:Gem::Version
73
- version: 0.11.0
74
- - !ruby/object:Gem::Dependency
75
- name: dry-monads
76
62
  requirement: !ruby/object:Gem::Requirement
77
63
  requirements:
78
64
  - - "~>"
79
65
  - !ruby/object:Gem::Version
80
- version: '1.6'
66
+ version: '0.11'
81
67
  type: :runtime
82
68
  prerelease: false
83
69
  version_requirements: !ruby/object:Gem::Requirement
84
70
  requirements:
85
71
  - - "~>"
86
72
  - !ruby/object:Gem::Version
87
- version: '1.6'
73
+ version: '0.11'
88
74
  - !ruby/object:Gem::Dependency
89
75
  name: memery
90
76
  requirement: !ruby/object:Gem::Requirement
@@ -166,7 +152,6 @@ extensions: []
166
152
  extra_rdoc_files: []
167
153
  files:
168
154
  - ".evilution.yml"
169
- - ".github/copilot-instructions.md"
170
155
  - ".github/dependabot.yml"
171
156
  - ".github/workflows/bundle_audit.yml"
172
157
  - ".github/workflows/ci.yml"
@@ -175,6 +160,7 @@ files:
175
160
  - ".rspec"
176
161
  - ".rubocop.yml"
177
162
  - ".rubocop_todo.yml"
163
+ - CHANGELOG.md
178
164
  - Gemfile
179
165
  - Gemfile.lock
180
166
  - LICENSE
@@ -196,12 +182,21 @@ files:
196
182
  - lib/pg_objects/parsed_object.rb
197
183
  - lib/pg_objects/parsed_object/aggregate.rb
198
184
  - lib/pg_objects/parsed_object/base.rb
185
+ - lib/pg_objects/parsed_object/base_type.rb
199
186
  - lib/pg_objects/parsed_object/conversion.rb
187
+ - lib/pg_objects/parsed_object/domain.rb
188
+ - lib/pg_objects/parsed_object/enum_type.rb
200
189
  - lib/pg_objects/parsed_object/event_trigger.rb
190
+ - lib/pg_objects/parsed_object/extension.rb
201
191
  - lib/pg_objects/parsed_object/function.rb
192
+ - lib/pg_objects/parsed_object/index.rb
202
193
  - lib/pg_objects/parsed_object/materialized_view.rb
203
194
  - lib/pg_objects/parsed_object/operator.rb
204
195
  - lib/pg_objects/parsed_object/operator_class.rb
196
+ - lib/pg_objects/parsed_object/policy.rb
197
+ - lib/pg_objects/parsed_object/range_type.rb
198
+ - lib/pg_objects/parsed_object/rule.rb
199
+ - lib/pg_objects/parsed_object/sequence.rb
205
200
  - lib/pg_objects/parsed_object/table.rb
206
201
  - lib/pg_objects/parsed_object/text_search_parser.rb
207
202
  - lib/pg_objects/parsed_object/text_search_template.rb
@@ -221,6 +216,7 @@ licenses:
221
216
  metadata:
222
217
  allowed_push_host: https://rubygems.org
223
218
  bug_tracker_uri: https://github.com/marinazzio/pg_objects/issues
219
+ changelog_uri: https://github.com/marinazzio/pg_objects/blob/master/CHANGELOG.md
224
220
  documentation_uri: https://github.com/marinazzio/pg_objects/blob/master/README.md
225
221
  homepage_uri: https://github.com/marinazzio/pg_objects
226
222
  rubygems_mfa_required: 'true'
@@ -237,14 +233,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
237
233
  requirements:
238
234
  - - ">="
239
235
  - !ruby/object:Gem::Version
240
- version: 3.2.0
236
+ version: 3.3.0
241
237
  required_rubygems_version: !ruby/object:Gem::Requirement
242
238
  requirements:
243
239
  - - ">="
244
240
  - !ruby/object:Gem::Version
245
241
  version: '0'
246
242
  requirements: []
247
- rubygems_version: 4.0.10
243
+ rubygems_version: 4.0.16
248
244
  specification_version: 4
249
245
  summary: Simple manager for PostgreSQL objects like triggers and functions
250
246
  test_files: []
@@ -1,131 +0,0 @@
1
- # PG Objects
2
- PG Objects is a Ruby gem for managing PostgreSQL database objects like triggers and functions. It provides a simple manager that handles dependencies between database objects and integrates with Rails applications.
3
-
4
- Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
5
-
6
- ## Working Effectively
7
- - Bootstrap, build, and test the repository:
8
- - `gem install --user-install bundler`
9
- - `export PATH="$HOME/.local/share/gem/ruby/3.2.0/bin:$PATH"`
10
- - `bundle config set --local path 'vendor/bundle'`
11
- - `bundle install` -- takes 45-60 seconds. NEVER CANCEL. Set timeout to 120+ seconds.
12
- - `bundle exec rspec spec` -- takes 4 seconds. NEVER CANCEL. Set timeout to 60+ seconds.
13
- - `bundle exec rubocop` -- takes 3 seconds. NEVER CANCEL. Set timeout to 60+ seconds.
14
- - `bundle exec bundle-audit check` -- takes 2 seconds (first run downloads advisory database). NEVER CANCEL. Set timeout to 180+ seconds for first run.
15
- - Performance benchmarking:
16
- - `bundle exec rake benchmark` -- takes 1 second. NEVER CANCEL. Set timeout to 30+ seconds.
17
- - Interactive console:
18
- - `./bin/console` -- launches IRB with pg_objects loaded
19
- - Install gem locally:
20
- - `bundle exec rake install` -- takes 9 seconds. NEVER CANCEL. Set timeout to 120+ seconds.
21
-
22
- ## Validation
23
- - Always run through the complete test suite after making changes: `bundle exec rspec spec`
24
- - ALWAYS run linting before completing work: `bundle exec rubocop`
25
- - Always run bundle audit to check for security vulnerabilities: `bundle exec bundle-audit check`
26
- - Test parsing functionality with sample SQL files to ensure changes work correctly
27
- - NEVER CANCEL builds or tests - they complete quickly (under 60 seconds)
28
-
29
- ## Common Tasks
30
- The following are outputs from frequently run commands. Reference them instead of viewing, searching, or running bash commands to save time.
31
-
32
- ### Repository Root Structure
33
- ```
34
- .
35
- ├── .github/ # CI/CD workflows (ci.yml, bundle_audit.yml, publish.yml)
36
- ├── .rspec # RSpec configuration
37
- ├── .rubocop.yml # RuboCop linting configuration
38
- ├── bin/
39
- │ ├── setup # Setup script (runs bundle install)
40
- │ ├── console # Interactive console
41
- │ └── benchmark # Performance benchmark tool
42
- ├── lib/
43
- │ ├── pg_objects.rb # Main entry point
44
- │ ├── pg_objects/ # Core library files
45
- │ │ ├── config.rb
46
- │ │ ├── manager.rb
47
- │ │ ├── parser.rb
48
- │ │ └── parsed_object/ # SQL object parsers
49
- │ └── generators/pg_objects/install/ # Rails generator
50
- ├── spec/ # RSpec test files
51
- ├── Gemfile # Gem dependencies
52
- ├── pg_objects.gemspec # Gem specification
53
- ├── Rakefile # Rake tasks (spec, benchmark)
54
- └── README.md # Documentation
55
- ```
56
-
57
- ### Key Files and Directories
58
- - **lib/pg_objects.rb**: Main entry point that requires all components
59
- - **lib/pg_objects/manager.rb**: Core manager for database objects
60
- - **lib/pg_objects/parser.rb**: SQL parsing and dependency extraction
61
- - **lib/pg_objects/parsed_object/**: Specific parsers for different SQL object types
62
- - **spec/**: Complete test suite with fixtures
63
- - **bin/benchmark**: Performance benchmarking tool with detailed metrics
64
- - **Gemfile**: Development and test dependencies (RSpec, RuboCop, etc.)
65
-
66
- ### Gemfile Dependencies
67
- - **Runtime**: activerecord, dry-auto_inject, dry-configurable, pg_query, railties
68
- - **Development/Test**: rspec, rubocop, bundler-audit, faker, pry-byebug
69
-
70
- ### Common Command Outputs
71
- #### `bundle exec rspec spec` (Expected: ~4 seconds, 54 examples, 0 failures)
72
- ```
73
- 54 examples, 0 failures
74
- Finished in 2.24 seconds
75
- ```
76
-
77
- #### `bundle exec rubocop` (Expected: ~3 seconds, 60 files, no offenses)
78
- ```
79
- 60 files inspected, no offenses detected
80
- ```
81
-
82
- #### `bundle exec bundle-audit check` (Expected: ~2 seconds after initial setup)
83
- ```
84
- No vulnerabilities found
85
- ```
86
-
87
- #### `bundle exec rake benchmark` (Expected: ~1 second)
88
- ```
89
- PG Objects Performance Benchmark
90
- ==================================================
91
- File I/O Performance: ~100,000+ files/s
92
- Parsing Performance: ~7,000 files/s
93
- Full Workflow Performance: ~6,000 objects/s
94
- Benchmark completed successfully!
95
- ```
96
-
97
- ## Development Workflow
98
- 1. Always run `bundle install` after cloning or changing dependencies
99
- 2. Make changes to code in lib/ directory
100
- 3. Add or update tests in spec/ directory for any changes
101
- 4. Run `bundle exec rspec spec` to ensure all tests pass
102
- 5. Run `bundle exec rubocop` to ensure code style compliance
103
- 6. Use `bundle exec rake benchmark` to test performance impact
104
- 7. Run `bundle exec bundle-audit check` for security validation
105
-
106
- ## Troubleshooting
107
- - If bundler is not found: `gem install --user-install bundler && export PATH="$HOME/.local/share/gem/ruby/3.2.0/bin:$PATH"`
108
- - If bundle install fails with permission errors: `bundle config set --local path 'vendor/bundle'`
109
- - Ruby version required: >= 3.2.0 (tested with 3.2, 3.3, 3.4)
110
- - The gem requires PostgreSQL and uses pg_query for SQL parsing
111
- - Dependencies include ActiveRecord, dry gems, and memery for caching
112
-
113
- ## Testing SQL Parsing
114
- Create test SQL files with dependencies:
115
- ```sql
116
- --!depends_on other_function
117
- CREATE OR REPLACE FUNCTION my_function(param INTEGER)
118
- RETURNS INTEGER AS $$
119
- BEGIN
120
- RETURN param * 2;
121
- END;
122
- $$ LANGUAGE plpgsql;
123
- ```
124
-
125
- Test parsing with:
126
- ```ruby
127
- parser = PgObjects::Parser.new
128
- content = File.read('path/to/file.sql')
129
- object_name = parser.load(content).fetch_object_name
130
- dependencies = parser.fetch_directives[:depends_on]
131
- ```