sequel-duckdb 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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.beads/.beads-credential-key +1 -0
  3. data/.beads/.gitignore +66 -0
  4. data/.beads/README.md +85 -0
  5. data/.beads/config.yaml +56 -0
  6. data/.beads/hooks/post-checkout +24 -0
  7. data/.beads/hooks/post-merge +24 -0
  8. data/.beads/hooks/pre-commit +24 -0
  9. data/.beads/hooks/pre-push +24 -0
  10. data/.beads/hooks/prepare-commit-msg +24 -0
  11. data/.beads/metadata.json +7 -0
  12. data/.kiro/specs/advanced-sql-features-implementation/design.md +3 -1
  13. data/.kiro/specs/advanced-sql-features-implementation/requirements.md +1 -1
  14. data/.kiro/specs/advanced-sql-features-implementation/tasks.md +5 -1
  15. data/.kiro/specs/duckdb-sql-syntax-compatibility/design.md +15 -1
  16. data/.kiro/specs/duckdb-sql-syntax-compatibility/requirements.md +1 -1
  17. data/.kiro/specs/duckdb-sql-syntax-compatibility/tasks.md +13 -0
  18. data/.kiro/specs/edge-cases-and-validation-fixes/requirements.md +1 -1
  19. data/.kiro/specs/integration-test-database-setup/requirements.md +1 -1
  20. data/.kiro/specs/sequel-duckdb-adapter/design.md +8 -1
  21. data/.kiro/specs/sequel-duckdb-adapter/requirements.md +10 -10
  22. data/.kiro/specs/sequel-duckdb-adapter/tasks.md +48 -3
  23. data/.kiro/specs/sql-expression-handling-fix/design.md +34 -1
  24. data/.kiro/specs/sql-expression-handling-fix/requirements.md +1 -1
  25. data/.kiro/specs/sql-expression-handling-fix/tasks.md +3 -0
  26. data/.kiro/specs/test-infrastructure-improvements/requirements.md +1 -1
  27. data/.kiro/steering/product.md +5 -1
  28. data/.kiro/steering/structure.md +1 -1
  29. data/.kiro/steering/tech.md +14 -1
  30. data/.kiro/steering/testing.md +22 -1
  31. data/.mdformat.toml +2 -0
  32. data/.release-please-manifest.json +3 -0
  33. data/.rubocop.yml +116 -58
  34. data/.rubocop_todo.yml +323 -0
  35. data/AGENTS.md +154 -0
  36. data/API_DOCUMENTATION.md +73 -49
  37. data/CHANGELOG.md +46 -10
  38. data/FINAL_STATUS.md +99 -0
  39. data/LICENSE +1 -1
  40. data/MIGRATION_EXAMPLES.md +1 -1
  41. data/PERFORMANCE_OPTIMIZATIONS.md +4 -1
  42. data/README.md +90 -1
  43. data/REFACTORING_SUMMARY.md +264 -0
  44. data/Rakefile +21 -5
  45. data/TASK_10.2_IMPLEMENTATION_SUMMARY.md +19 -1
  46. data/docs/DUCKDB_SQL_PATTERNS.md +39 -1
  47. data/docs/TASK_12_VERIFICATION_SUMMARY.md +14 -1
  48. data/justfile +52 -0
  49. data/lib/sequel/adapters/duckdb.rb +137 -108
  50. data/lib/sequel/adapters/shared/duckdb.rb +292 -1490
  51. data/lib/sequel/duckdb/helpers/copier.rb +50 -0
  52. data/lib/sequel/duckdb/helpers/pathifier.rb +141 -0
  53. data/lib/sequel/duckdb/version.rb +5 -2
  54. data/plans/date_arithmetic.md +420 -0
  55. data/plans/engineering/Sequel.md +471 -0
  56. data/plans/engineering/duckdb.md +712 -0
  57. data/plans/engineering/sqlite.md +453 -0
  58. data/plans/mock_connection_bug.md +333 -0
  59. data/plans/mock_without_driver_gem.md +371 -0
  60. data/plans/over_engineering_analysis.md +122 -0
  61. data/plans/schema_management.md +383 -0
  62. data/release-please-config.json +14 -0
  63. metadata +49 -27
@@ -1,10 +1,12 @@
1
1
  # Technology Stack
2
2
 
3
3
  ## Language & Runtime
4
+
4
5
  - **Ruby**: 3.1+ required
5
6
  - **Gem**: Standard Ruby gem structure
6
7
 
7
8
  ## Dependencies
9
+
8
10
  - **Sequel**: Database toolkit (core dependency)
9
11
  - **duckdb**: Official DuckDB client gem for connections
10
12
  - **DuckDB**: Target database system
@@ -13,16 +15,19 @@
13
15
  - **RuboCop**: Code linting and style enforcement
14
16
 
15
17
  ## Testing Framework
18
+
16
19
  - **Minitest**: Ruby's built-in testing framework (following sequel-hexspace pattern)
17
20
  - **Sequel Mock Database**: For SQL generation testing without database connections
18
21
  - **DuckDB In-Memory**: For integration testing with actual database instances
19
22
 
20
23
  ## Development Tools
24
+
21
25
  - **IRB**: Interactive Ruby console
22
26
  - **Git**: Version control
23
27
  - **GitHub Actions**: CI/CD (configured)
24
28
 
25
29
  ## Code Style & Quality
30
+
26
31
  - **RuboCop** configuration enforces:
27
32
  - Double quotes for string literals
28
33
  - Ruby 3.1 target version
@@ -31,6 +36,7 @@
31
36
  ## Common Commands
32
37
 
33
38
  ### Setup & Installation
39
+
34
40
  ```bash
35
41
  # Install dependencies
36
42
  bundle install
@@ -43,6 +49,7 @@ bin/console
43
49
  ```
44
50
 
45
51
  ### Development Workflow
52
+
46
53
  ```bash
47
54
  # Run tests (primary development command)
48
55
  bundle exec rake test
@@ -68,6 +75,7 @@ bundle exec rake release
68
75
  ```
69
76
 
70
77
  ### Testing Commands
78
+
71
79
  ```bash
72
80
  # Run all tests
73
81
  ruby test/all.rb
@@ -83,6 +91,7 @@ ruby test/database_test.rb -n test_connection
83
91
  ```
84
92
 
85
93
  ### Code Quality
94
+
86
95
  ```bash
87
96
  # Run RuboCop with auto-correct
88
97
  bundle exec rubocop -a
@@ -94,11 +103,13 @@ bundle exec rubocop lib/
94
103
  ## Coding Standards & References
95
104
 
96
105
  ### Primary Code Style Reference (in order of precedence)
106
+
97
107
  1. **jeremyevans/sequel**: Official Sequel repository - follow all conventions and idioms
98
108
  2. **sequel-hexspace**: Secondary reference for adapter patterns
99
109
  3. **sequel_impala**: Additional reference for implementation approaches
100
110
 
101
111
  ### Implementation Guidelines
112
+
102
113
  - Study git history of reference projects to understand implementation order
103
114
  - Focus on incremental, testable implementations
104
115
  - **ALWAYS write tests BEFORE implementing functionality (TDD)**
@@ -109,6 +120,7 @@ bundle exec rubocop lib/
109
120
  - Unit tests must use Sequel's mock database for SQL generation testing
110
121
 
111
122
  ### Testing Requirements (MANDATORY)
123
+
112
124
  - **Test Structure**: Follow sequel-hexspace test organization exactly
113
125
  - **Test Files**: Mirror sequel-hexspace test files (database_test.rb, dataset_test.rb, schema_test.rb, etc.)
114
126
  - **SQL Generation Tests**: Every SQL generation method must have unit tests verifying correct SQL output
@@ -119,6 +131,7 @@ bundle exec rubocop lib/
119
131
  - **Test Coverage**: Aim for 100% test coverage of all implemented functionality
120
132
 
121
133
  ### Connection Management
134
+
122
135
  - Use **duckdb** gem exclusively for database connections
123
136
  - Follow Sequel's connection pooling patterns
124
- - Implement proper error handling and connection lifecycle management
137
+ - Implement proper error handling and connection lifecycle management
@@ -12,6 +12,7 @@
12
12
  ## Test Structure (Following sequel-hexspace Pattern)
13
13
 
14
14
  ### Required Test Files
15
+
15
16
  ```
16
17
  test/
17
18
  ├── all.rb # Test runner - loads all test files
@@ -27,6 +28,7 @@ test/
27
28
  ### Test Categories
28
29
 
29
30
  #### 1. SQL Generation Tests (Unit Tests)
31
+
30
32
  - **Purpose**: Test SQL generation without database connections
31
33
  - **Tool**: Use Sequel's mock database functionality
32
34
  - **Requirements**:
@@ -37,6 +39,7 @@ test/
37
39
  - Test all SQL operations: SELECT, INSERT, UPDATE, DELETE, DDL
38
40
 
39
41
  #### 2. Integration Tests
42
+
40
43
  - **Purpose**: Test actual database operations
41
44
  - **Tool**: Use real DuckDB in-memory databases
42
45
  - **Requirements**:
@@ -47,6 +50,7 @@ test/
47
50
  - Test error handling with real database errors
48
51
 
49
52
  #### 3. Schema Tests
53
+
50
54
  - **Purpose**: Test schema operations and introspection
51
55
  - **Requirements**:
52
56
  - Test table creation, modification, and deletion
@@ -56,6 +60,7 @@ test/
56
60
  - Test DuckDB-specific schema features
57
61
 
58
62
  #### 4. Type Conversion Tests
63
+
59
64
  - **Purpose**: Test Ruby ↔ DuckDB type mapping
60
65
  - **Requirements**:
61
66
  - Test all supported data types
@@ -65,6 +70,7 @@ test/
65
70
  - Test binary data and text encoding
66
71
 
67
72
  #### 5. Error Handling Tests
73
+
68
74
  - **Purpose**: Test proper exception mapping and error scenarios
69
75
  - **Requirements**:
70
76
  - Test Sequel exception mapping
@@ -78,28 +84,33 @@ test/
78
84
  ### For Every Task Involving Code:
79
85
 
80
86
  1. **Step 1: Write Tests First**
87
+
81
88
  - Create comprehensive test cases covering the functionality
82
89
  - Include both positive and negative test cases
83
90
  - Test edge cases and error conditions
84
91
  - Ensure tests fail initially (Red phase)
85
92
 
86
93
  2. **Step 2: Minimal Implementation**
94
+
87
95
  - Write the minimal code needed to make tests pass
88
96
  - Focus on making tests green, not on perfect implementation
89
97
  - Avoid over-engineering at this stage
90
98
 
91
99
  3. **Step 3: Refactor**
100
+
92
101
  - Improve code quality while keeping tests green
93
102
  - Optimize performance if needed
94
103
  - Ensure code follows style guidelines
95
104
 
96
105
  4. **Step 4: Verify Coverage**
106
+
97
107
  - Ensure all implemented functionality has test coverage
98
108
  - Add additional tests if gaps are found
99
109
 
100
110
  ## Test Quality Standards
101
111
 
102
112
  ### Test Code Quality
113
+
103
114
  - Tests must be clear and readable
104
115
  - Test names should describe what is being tested
105
116
  - Tests should be independent and isolated
@@ -107,12 +118,14 @@ test/
107
118
  - Tests should run quickly (especially unit tests)
108
119
 
109
120
  ### Test Coverage Requirements
121
+
110
122
  - **100% line coverage** for all implemented functionality
111
123
  - **Branch coverage** for all conditional logic
112
124
  - **Edge case coverage** for error conditions
113
125
  - **Integration coverage** for database operations
114
126
 
115
127
  ### Test Documentation
128
+
116
129
  - Each test file should have a header explaining its purpose
117
130
  - Complex test setups should be documented
118
131
  - Test utilities should be well-documented
@@ -121,6 +134,7 @@ test/
121
134
  ## Tools and Utilities
122
135
 
123
136
  ### Mock Database Testing
137
+
124
138
  ```ruby
125
139
  # Example of mock database testing for SQL generation
126
140
  DB = Sequel.mock
@@ -129,6 +143,7 @@ assert_equal "SELECT * FROM users WHERE (name = 'John')", dataset.sql
129
143
  ```
130
144
 
131
145
  ### Integration Testing Setup
146
+
132
147
  ```ruby
133
148
  # Example of integration testing with real DuckDB
134
149
  def setup
@@ -143,12 +158,14 @@ end
143
158
  ## Continuous Integration
144
159
 
145
160
  ### Test Execution
161
+
146
162
  - All tests must pass before any code is merged
147
163
  - Tests should be run on multiple Ruby versions
148
164
  - Tests should be run on different operating systems
149
165
  - Performance regression tests should be included
150
166
 
151
167
  ### Test Reporting
168
+
152
169
  - Test results should be clearly reported
153
170
  - Coverage reports should be generated
154
171
  - Failed tests should provide clear error messages
@@ -157,6 +174,7 @@ end
157
174
  ## Common Testing Patterns
158
175
 
159
176
  ### Testing SQL Generation
177
+
160
178
  ```ruby
161
179
  def test_select_with_where
162
180
  dataset = @db[:users].where(name: 'John')
@@ -165,6 +183,7 @@ end
165
183
  ```
166
184
 
167
185
  ### Testing Database Operations
186
+
168
187
  ```ruby
169
188
  def test_insert_and_select
170
189
  @db[:users].insert(name: 'John', email: 'john@example.com')
@@ -174,6 +193,7 @@ end
174
193
  ```
175
194
 
176
195
  ### Testing Error Conditions
196
+
177
197
  ```ruby
178
198
  def test_connection_error
179
199
  assert_raises(Sequel::DatabaseConnectionError) do
@@ -185,8 +205,9 @@ end
185
205
  ## Remember: NO CODE WITHOUT TESTS
186
206
 
187
207
  This is not optional. Every implementation task must begin with writing comprehensive tests. This ensures:
208
+
188
209
  - Functionality works as expected
189
210
  - Regressions are caught early
190
211
  - Code is maintainable and refactorable
191
212
  - Documentation through executable examples
192
- - Confidence in the codebase
213
+ - Confidence in the codebase
data/.mdformat.toml ADDED
@@ -0,0 +1,2 @@
1
+ extensions = ["frontmatter", "gfm"]
2
+ number = true
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.2.0"
3
+ }
data/.rubocop.yml CHANGED
@@ -1,103 +1,161 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  plugins:
2
4
  - rubocop-minitest
3
5
  - rubocop-rake
4
6
  - rubocop-sequel
5
7
 
6
8
  AllCops:
7
- TargetRubyVersion: 3.1
9
+ TargetRubyVersion: 4.0
8
10
  NewCops: enable
11
+ SuggestExtensions: false
12
+ Exclude:
13
+ - 'vendor/**/*'
14
+ - 'bin/**/*'
15
+ - 'tmp/**/*'
9
16
 
10
- Gemspec/DevelopmentDependencies:
17
+ inherit_mode:
18
+ merge:
19
+ - Exclude
20
+
21
+ Layout/IndentationWidth:
22
+ Width: 2
23
+
24
+ Style/StringLiterals:
25
+ EnforcedStyle: double_quotes
26
+
27
+ Style/StringLiteralsInInterpolation:
28
+ EnforcedStyle: double_quotes
29
+
30
+ Style/DefWithParentheses:
11
31
  Enabled: false
12
32
 
13
- # Disable complexity violations for database adapter code
14
- Metrics/ModuleLength:
33
+ Style/MethodCallWithoutArgsParentheses:
15
34
  Enabled: true
35
+
36
+ Layout/LineLength:
37
+ Max: 120
38
+ AllowedPatterns: ['\A\s*#']
16
39
  Exclude:
17
- - lib/sequel/adapters/shared/duckdb.rb
40
+ - '*.gemspec'
41
+ - 'test/**/*'
18
42
 
19
- Metrics/MethodLength:
43
+ Style/Documentation:
44
+ Enabled: false
45
+
46
+ Style/FrozenStringLiteralComment:
47
+ Enabled: false
48
+
49
+ Style/Lambda:
50
+ Enabled: false
51
+
52
+ Style/ParallelAssignment:
53
+ Enabled: false
54
+
55
+ Style/GuardClause:
20
56
  Enabled: true
21
- Exclude:
22
- - lib/sequel/adapters/shared/duckdb.rb
23
- - test/**/*
24
- - test/type_test.rb
25
57
 
26
- Metrics/ClassLength:
58
+ Style/IfUnlessModifier:
27
59
  Enabled: true
28
- Exclude:
29
- - test/**/*
30
- - test/type_test.rb
60
+
61
+ Metrics/MethodLength:
62
+ Max: 25
63
+
64
+ Metrics/ClassLength:
65
+ Max: 200
66
+
67
+ Metrics/ModuleLength:
68
+ Max: 200
31
69
 
32
70
  Metrics/BlockLength:
33
- Enabled: true
71
+ Max: 50
34
72
  Exclude:
35
- - test/**/*
36
- - test/type_test.rb
37
- - sequel-duckdb.gemspec
73
+ - 'test/**/*'
74
+ - '*.gemspec'
75
+ - 'Rakefile'
76
+
77
+ Style/ZeroLengthPredicate:
78
+ Enabled: false
79
+
80
+ Naming/MemoizedInstanceVariableName:
81
+ Enabled: false
82
+
83
+ Naming/MethodParameterName:
84
+ MinNameLength: 1
85
+
86
+ Style/MultilineBlockChain:
87
+ Enabled: false
38
88
 
39
89
  Metrics/AbcSize:
40
- Enabled: true
90
+ Max: 35
41
91
  Exclude:
42
- - lib/sequel/adapters/shared/duckdb.rb
43
- - test/**/*
44
- - test/type_test.rb
92
+ - 'test/**/*'
45
93
 
46
94
  Metrics/CyclomaticComplexity:
47
- Enabled: true
48
- Exclude:
49
- - lib/sequel/adapters/shared/duckdb.rb
50
- - test/**/*
51
- - test/type_test.rb
95
+ Max: 15
52
96
 
53
97
  Metrics/PerceivedComplexity:
98
+ Max: 12
99
+
100
+ Metrics/BlockNesting:
101
+ Max: 4
102
+
103
+ Naming/AccessorMethodName:
104
+ Enabled: false
105
+
106
+ Style/HashSyntax:
107
+ EnforcedStyle: ruby19
108
+ EnforcedShorthandSyntax: either
109
+
110
+ Minitest/AssertEqual:
54
111
  Enabled: true
55
- Exclude:
56
- - lib/sequel/adapters/shared/duckdb.rb
57
- - test/**/*
58
- - test/type_test.rb
59
112
 
60
- # Disable line length for generated SQL and complex expressions
61
- Layout/LineLength:
113
+ Minitest/RefuteEqual:
62
114
  Enabled: true
63
- Exclude:
64
- - test/**/*
65
- - test/type_test.rb
66
- - sequel-duckdb.gemspec
67
115
 
68
116
  Minitest/MultipleAssertions:
69
117
  Enabled: false
70
118
 
71
- # Allow duplicate branches for error handling patterns
72
- Lint/DuplicateBranch:
73
- Enabled: true
119
+ Layout/EmptyLinesAroundClassBody:
120
+ EnforcedStyle: empty_lines_except_namespace
74
121
 
75
- # Allow database adapter naming patterns
76
- Naming/MethodParameterName:
77
- Enabled: true
122
+ Layout/EmptyLinesAroundModuleBody:
123
+ EnforcedStyle: empty_lines_except_namespace
78
124
 
79
- Naming/AccessorMethodName:
80
- Enabled: true
125
+ Style/TrailingCommaInArguments:
126
+ EnforcedStyleForMultiline: comma
127
+
128
+ Style/TrailingCommaInArrayLiteral:
129
+ EnforcedStyleForMultiline: comma
130
+
131
+ Style/TrailingCommaInHashLiteral:
132
+ EnforcedStyleForMultiline: comma
133
+
134
+ Gemspec/DevelopmentDependencies:
135
+ Enabled: false
136
+
137
+ Style/HashLikeCase:
138
+ Exclude:
139
+ - 'test/**/*'
140
+
141
+ Lint/DuplicateBranch:
142
+ Exclude:
143
+ - 'test/**/*'
144
+
145
+ Style/StringConcatenation:
146
+ Exclude:
147
+ - 'test/**/*'
81
148
 
82
149
  Naming/VariableNumber:
83
- Enabled: true
84
150
  Exclude:
85
- - test/**/*
151
+ - 'test/**/*'
86
152
 
87
- # Allow database adapter patterns
88
153
  Lint/EmptyBlock:
89
- Enabled: true
90
154
  Exclude:
91
- - test/**/*
92
-
93
- Lint/DuplicateMethods:
94
- Enabled: true
155
+ - 'test/**/*'
95
156
 
96
157
  Style/TrivialAccessors:
97
158
  Enabled: true
98
159
 
99
- Style/StringLiterals:
100
- EnforcedStyle: double_quotes
101
-
102
- Style/StringLiteralsInInterpolation:
103
- EnforcedStyle: double_quotes
160
+ Lint/DuplicateMethods:
161
+ Enabled: true