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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb4c8565280c6828b7fd8122ca87de1867da66e4cc5c7f4b640a0b34ee1880ac
4
- data.tar.gz: c415c11256156a1b21e6b5f02268e2f22a786f3ce240e17596d6ba0e61f5a460
3
+ metadata.gz: 4767efb050303f1b91acddbbe01fd263d1230bb02e1747c013728856d4ceb1b2
4
+ data.tar.gz: d266f8c0f5169da511c887cc8902d1b288b66c0e67459a1a21873378991d2e58
5
5
  SHA512:
6
- metadata.gz: d282d7015f97c66fa0a9581552be9ff189b07dbf7678dca94a8990070d42f66335f2359056ca9fbeed4e8b1a89da1afc03884a0ba8994ecda23fc9e1282d5048
7
- data.tar.gz: 237ea21f9f3a6d2d148b85e9f4f0338864efe2055b426c5a169ff2d2e3775f54f91957a10e061869066c414921abfc1fd0ae15c375090573e9bd1aa38575b7fd
6
+ metadata.gz: 19448226d83feefa1708018c918af2f94178ebc5b888ea116b59e11cd7f24f151843544b064030bb81701825516c3e0aebab70301ee4dbd79922b43d6c4db436
7
+ data.tar.gz: a1d751a3e64769fdad344fec138a29860568acf5d9930b972b2893fc4008c25cd5fc5798ab93a20192fc8f5563d3fa5bfade189affb75a1c8b51aa6efdc93b93
@@ -0,0 +1 @@
1
+ �:I>����G��O�FԤ�L1 s<j�,
data/.beads/.gitignore ADDED
@@ -0,0 +1,66 @@
1
+ # Dolt database (managed by Dolt, not git)
2
+ dolt/
3
+ dolt-access.lock
4
+
5
+ # Runtime files
6
+ bd.sock
7
+ bd.sock.startlock
8
+ sync-state.json
9
+ last-touched
10
+ .exclusive-lock
11
+
12
+ # Daemon runtime (lock, log, pid)
13
+ daemon.*
14
+
15
+ # Interactions log (runtime, not versioned)
16
+ interactions.jsonl
17
+
18
+ # Push state (runtime, per-machine)
19
+ push-state.json
20
+
21
+ # Lock files (various runtime locks)
22
+ *.lock
23
+
24
+ # Local version tracking (prevents upgrade notification spam after git ops)
25
+ .local_version
26
+
27
+ # Worktree redirect file (contains relative path to main repo's .beads/)
28
+ # Must not be committed as paths would be wrong in other clones
29
+ redirect
30
+
31
+ # Sync state (local-only, per-machine)
32
+ # These files are machine-specific and should not be shared across clones
33
+ .sync.lock
34
+ export-state/
35
+
36
+ # Ephemeral store (SQLite - wisps/molecules, intentionally not versioned)
37
+ ephemeral.sqlite3
38
+ ephemeral.sqlite3-journal
39
+ ephemeral.sqlite3-wal
40
+ ephemeral.sqlite3-shm
41
+
42
+ # Dolt server management (auto-started by bd)
43
+ dolt-server.pid
44
+ dolt-server.log
45
+ dolt-server.lock
46
+ dolt-server.port
47
+
48
+ # Corrupt backup directories (created by bd doctor --fix recovery)
49
+ *.corrupt.backup/
50
+
51
+ # Backup data (auto-exported JSONL, local-only)
52
+ backup/
53
+
54
+ # Legacy files (from pre-Dolt versions)
55
+ *.db
56
+ *.db?*
57
+ *.db-journal
58
+ *.db-wal
59
+ *.db-shm
60
+ db.sqlite
61
+ bd.db
62
+ # NOTE: Do NOT add negation patterns here.
63
+ # They would override fork protection in .git/info/exclude.
64
+ # Config files (metadata.json, config.yaml) are tracked by git by default
65
+ # since no pattern above ignores them.
66
+ .beads-credential-key
data/.beads/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # Beads - AI-Native Issue Tracking
2
+
3
+ Welcome to Beads! This repository uses **Beads** for issue tracking - a modern, AI-native tool designed to live directly in your codebase alongside your code.
4
+
5
+ ## What is Beads?
6
+
7
+ Beads is issue tracking that lives in your repo, making it perfect for AI coding agents and developers who want their issues close to their code. No web UI required - everything works through the CLI and integrates seamlessly with git.
8
+
9
+ **Learn more:** [github.com/steveyegge/beads](https://github.com/steveyegge/beads)
10
+
11
+ ## Quick Start
12
+
13
+ ### Essential Commands
14
+
15
+ ```bash
16
+ # Create new issues
17
+ bd create "Add user authentication"
18
+
19
+ # View all issues
20
+ bd list
21
+
22
+ # View issue details
23
+ bd show <issue-id>
24
+
25
+ # Update issue status
26
+ bd update <issue-id> --claim
27
+ bd update <issue-id> --status done
28
+
29
+ # Sync with Dolt remote
30
+ bd dolt push
31
+ ```
32
+
33
+ ### Working with Issues
34
+
35
+ Issues in Beads are:
36
+
37
+ - **Git-native**: Stored in Dolt database with version control and branching
38
+ - **AI-friendly**: CLI-first design works perfectly with AI coding agents
39
+ - **Branch-aware**: Issues can follow your branch workflow
40
+ - **Always in sync**: Auto-syncs with your commits
41
+
42
+ ## Why Beads?
43
+
44
+ ✨ **AI-Native Design**
45
+
46
+ - Built specifically for AI-assisted development workflows
47
+ - CLI-first interface works seamlessly with AI coding agents
48
+ - No context switching to web UIs
49
+
50
+ 🚀 **Developer Focused**
51
+
52
+ - Issues live in your repo, right next to your code
53
+ - Works offline, syncs when you push
54
+ - Fast, lightweight, and stays out of your way
55
+
56
+ 🔧 **Git Integration**
57
+
58
+ - Automatic sync with git commits
59
+ - Branch-aware issue tracking
60
+ - Dolt-native three-way merge resolution
61
+
62
+ ## Get Started with Beads
63
+
64
+ Try Beads in your own projects:
65
+
66
+ ```bash
67
+ # Install Beads
68
+ curl -sSL https://raw.githubusercontent.com/steveyegge/beads/main/scripts/install.sh | bash
69
+
70
+ # Initialize in your repo
71
+ bd init
72
+
73
+ # Create your first issue
74
+ bd create "Try out Beads"
75
+ ```
76
+
77
+ ## Learn More
78
+
79
+ - **Documentation**: [github.com/steveyegge/beads/docs](https://github.com/steveyegge/beads/tree/main/docs)
80
+ - **Quick Start Guide**: Run `bd quickstart`
81
+ - **Examples**: [github.com/steveyegge/beads/examples](https://github.com/steveyegge/beads/tree/main/examples)
82
+
83
+ ______________________________________________________________________
84
+
85
+ *Beads: Issue tracking that moves at the speed of thought* ⚡
@@ -0,0 +1,56 @@
1
+ # Beads Configuration File
2
+ # This file configures default behavior for all bd commands in this repository
3
+ # All settings can also be set via environment variables (BD_* prefix)
4
+ # or overridden with command-line flags
5
+
6
+ # Issue prefix for this repository (used by bd init)
7
+ # If not set, bd init will auto-detect from directory name
8
+ # Example: issue-prefix: "myproject" creates issues like "myproject-1", "myproject-2", etc.
9
+ # issue-prefix: ""
10
+
11
+ # Use no-db mode: JSONL-only, no Dolt database
12
+ # When true, bd will use .beads/issues.jsonl as the source of truth
13
+ # no-db: false
14
+
15
+ # Enable JSON output by default
16
+ # json: false
17
+
18
+ # Feedback title formatting for mutating commands (create/update/close/dep/edit)
19
+ # 0 = hide titles, N > 0 = truncate to N characters
20
+ # output:
21
+ # title-length: 255
22
+
23
+ # Default actor for audit trails (overridden by BD_ACTOR or --actor)
24
+ # actor: ""
25
+
26
+ # Export events (audit trail) to .beads/events.jsonl on each flush/sync
27
+ # When enabled, new events are appended incrementally using a high-water mark.
28
+ # Use 'bd export --events' to trigger manually regardless of this setting.
29
+ # events-export: false
30
+
31
+ # Multi-repo configuration (experimental - bd-307)
32
+ # Allows hydrating from multiple repositories and routing writes to the correct database
33
+ # repos:
34
+ # primary: "." # Primary repo (where this database lives)
35
+ # additional: # Additional repos to hydrate from (read-only)
36
+ # - ~/beads-planning # Personal planning repo
37
+ # - ~/work-planning # Work planning repo
38
+
39
+ # JSONL backup (periodic export for off-machine recovery)
40
+ # Auto-enabled when a git remote exists. Override explicitly:
41
+ # backup:
42
+ # enabled: false # Disable auto-backup entirely
43
+ # interval: 15m # Minimum time between auto-exports
44
+ # git-push: false # Disable git push (export locally only)
45
+ # git-repo: "" # Separate git repo for backups (default: project repo)
46
+
47
+ # Integration settings (access with 'bd config get/set')
48
+ # These are stored in the database, not in this file:
49
+ # - jira.url
50
+ # - jira.project
51
+ # - linear.url
52
+ # - linear.api-key
53
+ # - github.org
54
+ # - github.repo
55
+
56
+ sync.remote: "git+ssh://git@github.com/outcomesinsights/sequel-duckdb.git"
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env sh
2
+ # --- BEGIN BEADS INTEGRATION v0.61.0 ---
3
+ # This section is managed by beads. Do not remove these markers.
4
+ if command -v bd >/dev/null 2>&1; then
5
+ export BD_GIT_HOOK=1
6
+ _bd_timeout=${BEADS_HOOK_TIMEOUT:-30}
7
+ if command -v timeout >/dev/null 2>&1; then
8
+ timeout "$_bd_timeout" bd hooks run post-checkout "$@"
9
+ _bd_exit=$?
10
+ if [ $_bd_exit -eq 124 ]; then
11
+ echo >&2 "beads: hook 'post-checkout' timed out after ${_bd_timeout}s — continuing without beads"
12
+ _bd_exit=0
13
+ fi
14
+ else
15
+ bd hooks run post-checkout "$@"
16
+ _bd_exit=$?
17
+ fi
18
+ if [ $_bd_exit -eq 3 ]; then
19
+ echo >&2 "beads: database not initialized — skipping hook 'post-checkout'"
20
+ _bd_exit=0
21
+ fi
22
+ if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
23
+ fi
24
+ # --- END BEADS INTEGRATION v0.61.0 ---
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env sh
2
+ # --- BEGIN BEADS INTEGRATION v0.61.0 ---
3
+ # This section is managed by beads. Do not remove these markers.
4
+ if command -v bd >/dev/null 2>&1; then
5
+ export BD_GIT_HOOK=1
6
+ _bd_timeout=${BEADS_HOOK_TIMEOUT:-30}
7
+ if command -v timeout >/dev/null 2>&1; then
8
+ timeout "$_bd_timeout" bd hooks run post-merge "$@"
9
+ _bd_exit=$?
10
+ if [ $_bd_exit -eq 124 ]; then
11
+ echo >&2 "beads: hook 'post-merge' timed out after ${_bd_timeout}s — continuing without beads"
12
+ _bd_exit=0
13
+ fi
14
+ else
15
+ bd hooks run post-merge "$@"
16
+ _bd_exit=$?
17
+ fi
18
+ if [ $_bd_exit -eq 3 ]; then
19
+ echo >&2 "beads: database not initialized — skipping hook 'post-merge'"
20
+ _bd_exit=0
21
+ fi
22
+ if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
23
+ fi
24
+ # --- END BEADS INTEGRATION v0.61.0 ---
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env sh
2
+ # --- BEGIN BEADS INTEGRATION v0.61.0 ---
3
+ # This section is managed by beads. Do not remove these markers.
4
+ if command -v bd >/dev/null 2>&1; then
5
+ export BD_GIT_HOOK=1
6
+ _bd_timeout=${BEADS_HOOK_TIMEOUT:-30}
7
+ if command -v timeout >/dev/null 2>&1; then
8
+ timeout "$_bd_timeout" bd hooks run pre-commit "$@"
9
+ _bd_exit=$?
10
+ if [ $_bd_exit -eq 124 ]; then
11
+ echo >&2 "beads: hook 'pre-commit' timed out after ${_bd_timeout}s — continuing without beads"
12
+ _bd_exit=0
13
+ fi
14
+ else
15
+ bd hooks run pre-commit "$@"
16
+ _bd_exit=$?
17
+ fi
18
+ if [ $_bd_exit -eq 3 ]; then
19
+ echo >&2 "beads: database not initialized — skipping hook 'pre-commit'"
20
+ _bd_exit=0
21
+ fi
22
+ if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
23
+ fi
24
+ # --- END BEADS INTEGRATION v0.61.0 ---
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env sh
2
+ # --- BEGIN BEADS INTEGRATION v0.61.0 ---
3
+ # This section is managed by beads. Do not remove these markers.
4
+ if command -v bd >/dev/null 2>&1; then
5
+ export BD_GIT_HOOK=1
6
+ _bd_timeout=${BEADS_HOOK_TIMEOUT:-30}
7
+ if command -v timeout >/dev/null 2>&1; then
8
+ timeout "$_bd_timeout" bd hooks run pre-push "$@"
9
+ _bd_exit=$?
10
+ if [ $_bd_exit -eq 124 ]; then
11
+ echo >&2 "beads: hook 'pre-push' timed out after ${_bd_timeout}s — continuing without beads"
12
+ _bd_exit=0
13
+ fi
14
+ else
15
+ bd hooks run pre-push "$@"
16
+ _bd_exit=$?
17
+ fi
18
+ if [ $_bd_exit -eq 3 ]; then
19
+ echo >&2 "beads: database not initialized — skipping hook 'pre-push'"
20
+ _bd_exit=0
21
+ fi
22
+ if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
23
+ fi
24
+ # --- END BEADS INTEGRATION v0.61.0 ---
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env sh
2
+ # --- BEGIN BEADS INTEGRATION v0.61.0 ---
3
+ # This section is managed by beads. Do not remove these markers.
4
+ if command -v bd >/dev/null 2>&1; then
5
+ export BD_GIT_HOOK=1
6
+ _bd_timeout=${BEADS_HOOK_TIMEOUT:-30}
7
+ if command -v timeout >/dev/null 2>&1; then
8
+ timeout "$_bd_timeout" bd hooks run prepare-commit-msg "$@"
9
+ _bd_exit=$?
10
+ if [ $_bd_exit -eq 124 ]; then
11
+ echo >&2 "beads: hook 'prepare-commit-msg' timed out after ${_bd_timeout}s — continuing without beads"
12
+ _bd_exit=0
13
+ fi
14
+ else
15
+ bd hooks run prepare-commit-msg "$@"
16
+ _bd_exit=$?
17
+ fi
18
+ if [ $_bd_exit -eq 3 ]; then
19
+ echo >&2 "beads: database not initialized — skipping hook 'prepare-commit-msg'"
20
+ _bd_exit=0
21
+ fi
22
+ if [ $_bd_exit -ne 0 ]; then exit $_bd_exit; fi
23
+ fi
24
+ # --- END BEADS INTEGRATION v0.61.0 ---
@@ -0,0 +1,7 @@
1
+ {
2
+ "database": "dolt",
3
+ "backend": "dolt",
4
+ "dolt_mode": "embedded",
5
+ "dolt_server_host": "127.0.0.1",
6
+ "project_id": "5883e5bf-a919-4ca8-b7ee-d1cb7e08dfa5"
7
+ }
@@ -5,11 +5,13 @@
5
5
  Most advanced SQL features are already implemented. This focuses on verification, testing, and minor enhancements.
6
6
 
7
7
  **Status:**
8
+
8
9
  - JOIN USING, recursive CTEs, set operations, error handling: ✅ Implemented
9
10
  - Window functions: ✅ Basic support exists
10
11
  - DuckDB configuration: ✅ Basic PRAGMA support exists
11
12
 
12
13
  **Remaining Work:**
14
+
13
15
  - Test window functions with actual DuckDB
14
16
  - Test advanced expressions (arrays, JSON)
15
17
  - Add user-friendly configuration methods
@@ -21,4 +23,4 @@ Most advanced SQL features are already implemented. This focuses on verification
21
23
  2. **Add convenience methods** - User-friendly configuration interface
22
24
  3. **Integration testing** - Test with actual DuckDB databases
23
25
 
24
- This is primarily testing and verification, not new feature implementation.
26
+ This is primarily testing and verification, not new feature implementation.
@@ -40,4 +40,4 @@ Most advanced SQL features are already implemented. This focuses on remaining ve
40
40
  #### Acceptance Criteria
41
41
 
42
42
  1. WHEN I run tests THEN all advanced features SHALL work with actual DuckDB databases
43
- 2. WHEN errors occur THEN they SHALL be properly mapped to Sequel exceptions
43
+ 2. WHEN errors occur THEN they SHALL be properly mapped to Sequel exceptions
@@ -3,22 +3,26 @@
3
3
  Most advanced SQL features are already implemented. Remaining tasks based on current code analysis:
4
4
 
5
5
  - [x] 1. Test window functions
6
+
6
7
  - ~~Add tests to `test/dataset_test.rb` for ROW_NUMBER, RANK, DENSE_RANK~~ ✅ Already implemented
7
8
  - ~~Test LAG/LEAD functions with offset and default parameters~~ ✅ Already implemented
8
9
  - _Requirements: 1.1, 1.2_
9
10
 
10
11
  - [x] 2. Test advanced expressions
12
+
11
13
  - Add tests to `test/sql_test.rb` for DuckDB array syntax `[1, 2, 3]`
12
14
  - Test JSON functions like `json_extract`
13
15
  - _Requirements: 2.1, 2.2_
14
16
 
15
17
  - [x] 3. Add configuration convenience methods
18
+
16
19
  - Add `set_pragma(key, value)` method to `DatabaseMethods` (user-friendly wrapper)
17
20
  - Add `configure_duckdb(options)` method for batch configuration
18
21
  - Add tests to `test/database_test.rb`
19
22
  - _Requirements: 3.1, 3.2_
20
23
 
21
24
  - [x] 4. Integration testing
25
+
22
26
  - ~~Add integration tests to existing test files using actual DuckDB databases~~ ✅ Already implemented
23
27
  - ~~Test that all advanced features work together correctly~~ ✅ Already implemented
24
- - _Requirements: 4.1, 4.2_
28
+ - _Requirements: 4.1, 4.2_
@@ -162,6 +162,7 @@ Use existing Sequel error handling patterns. No special error handling needed fo
162
162
  ## Testing Strategy
163
163
 
164
164
  ### 1. SQL Generation Unit Tests
165
+
165
166
  - Test all SQL generation methods using Sequel's mock database functionality
166
167
  - Verify exact SQL syntax matches expected Sequel patterns
167
168
  - Test LIKE clauses generate clean SQL without ESCAPE clauses
@@ -171,12 +172,14 @@ Use existing Sequel error handling patterns. No special error handling needed fo
171
172
  - Test subquery column references use standard SQL format
172
173
 
173
174
  ### 2. Integration Tests
175
+
174
176
  - Ensure actual database operations work correctly with generated SQL
175
177
  - Verify functional correctness alongside syntactic correctness
176
178
  - Test correlated subqueries with proper column references
177
179
  - Test complex queries with multiple SQL generation features
178
180
 
179
181
  ### 3. Test Infrastructure Consistency
182
+
180
183
  - Fix SQL test infrastructure to use proper dataset creation
181
184
  - Ensure tests expect standard SQL syntax consistently
182
185
  - Maintain comprehensive test coverage for all SQL generation patterns
@@ -185,41 +188,50 @@ Use existing Sequel error handling patterns. No special error handling needed fo
185
188
  ## Design Decisions and Rationales
186
189
 
187
190
  ### 1. Fix Adapter SQL Generation
191
+
188
192
  **Decision**: Fix the root cause SQL generation issues in the adapter
189
193
  **Rationale**: The adapter is generating non-standard SQL that doesn't follow Sequel conventions. Tests are correct to expect standard SQL.
190
194
 
191
195
  ### 2. Targeted Method Overrides
196
+
192
197
  **Decision**: Override specific SQL generation methods in DatasetMethods
193
198
  **Rationale**: Surgical fixes to specific issues without disrupting the overall adapter architecture.
194
199
 
195
200
  ### 3. Standard SQL Compliance
201
+
196
202
  **Decision**: Generate SQL that follows standard SQL and Sequel conventions
197
203
  **Rationale**: Ensures compatibility with existing Sequel patterns and makes the adapter more predictable.
198
204
 
199
205
  ### 4. Maintain Test Coverage
206
+
200
207
  **Decision**: Keep all existing tests, fix the adapter to make them pass
201
208
  **Rationale**: Tests are validating correct behavior; the adapter should conform to expected patterns.
202
209
 
203
210
  ## Implementation Phases
204
211
 
205
212
  ### Phase 1: Fix LIKE and Complex Expression Generation
213
+
206
214
  - Override `complex_expression_sql_append` to fix LIKE, ILIKE, and regex generation
207
215
  - Add proper parentheses to all complex expressions
208
216
  - Remove unwanted ESCAPE clauses from LIKE statements
209
217
 
210
218
  ### Phase 2: Fix Table Alias Generation
219
+
211
220
  - Override table alias methods to use standard `AS` syntax
212
221
  - Ensure aliases work correctly in JOIN operations
213
222
 
214
223
  ### Phase 3: Fix Qualified Column References
224
+
215
225
  - Override qualified identifier methods to use dot notation
216
226
  - Ensure subqueries use proper column references
217
227
 
218
228
  ### Phase 4: Fix SQL Test Infrastructure
229
+
219
230
  - Fix dataset creation issues in SQL tests
220
231
  - Ensure tests use proper mock datasets
221
232
 
222
233
  ### Phase 5: Verification and Documentation
234
+
223
235
  - Run all tests to ensure they pass with fixed adapter
224
236
  - Document the SQL generation patterns used by the adapter
225
237
  - Create comprehensive documentation of DuckDB-specific SQL patterns
@@ -228,6 +240,7 @@ Use existing Sequel error handling patterns. No special error handling needed fo
228
240
  ## Documentation Strategy
229
241
 
230
242
  ### SQL Pattern Documentation
243
+
231
244
  To address Requirement 7, the adapter will include comprehensive documentation of SQL generation patterns:
232
245
 
233
246
  **Location**: `API_DOCUMENTATION.md` and inline code comments
@@ -239,6 +252,7 @@ To address Requirement 7, the adapter will include comprehensive documentation o
239
252
  5. **DuckDB-Specific Optimizations**: Document any DuckDB-specific SQL optimizations used
240
253
 
241
254
  **Example Documentation Structure**:
255
+
242
256
  ```ruby
243
257
  # SQL Generation Patterns for DuckDB Adapter
244
258
  #
@@ -255,4 +269,4 @@ To address Requirement 7, the adapter will include comprehensive documentation o
255
269
  # Output: users.id
256
270
  ```
257
271
 
258
- This design fixes the root causes of the SQL generation issues rather than working around them, resulting in a more robust and standards-compliant adapter.
272
+ This design fixes the root causes of the SQL generation issues rather than working around them, resulting in a more robust and standards-compliant adapter.
@@ -81,4 +81,4 @@ This specification addresses SQL generation issues in the sequel-duckdb adapter
81
81
  1. WHEN the adapter generates specific SQL patterns THEN they SHALL be documented
82
82
  2. WHEN SQL generation differs from other Sequel adapters THEN the differences SHALL be explained
83
83
  3. WHEN DuckDB-specific optimizations are used THEN they SHALL be documented with examples
84
- 4. WHEN SQL generation patterns change THEN documentation SHALL be updated accordingly
84
+ 4. WHEN SQL generation patterns change THEN documentation SHALL be updated accordingly
@@ -1,6 +1,7 @@
1
1
  # Implementation Plan
2
2
 
3
3
  - [x] 1. Identify failing tests and analyze DuckDB SQL generation
4
+
4
5
  - Run existing test suite to identify tests failing due to SQL syntax differences
5
6
  - Analyze what SQL the adapter currently generates vs what tests expect
6
7
  - Document the specific DuckDB syntax patterns that are being generated
@@ -8,6 +9,7 @@
8
9
  - _Requirements: 7.1, 7.2_
9
10
 
10
11
  - [x] 2. Fix LIKE clause ESCAPE handling in adapter
12
+
11
13
  - Current issue: LIKE generates `(name LIKE '%John%' ESCAPE '\')` instead of `(name LIKE '%John%')`
12
14
  - Override LIKE handling in `complex_expression_sql_append` to remove ESCAPE clause
13
15
  - Ensure LIKE clauses generate clean `(name LIKE '%John%')` without ESCAPE clause
@@ -15,6 +17,7 @@
15
17
  - _Requirements: 1.1, 1.2, 1.4_
16
18
 
17
19
  - [x] 3. Fix parentheses in complex expression SQL generation
20
+
18
21
  - Current issue: ILIKE generates `UPPER(name) LIKE UPPER('%john%')` without outer parentheses
19
22
  - Current issue: Regex generates `name ~ 'pattern'` without outer parentheses
20
23
  - Update `complex_expression_sql_append` to add proper parentheses around expressions
@@ -24,11 +27,13 @@
24
27
  - _Requirements: 1.3, 5.1, 5.2, 5.3, 5.4_
25
28
 
26
29
  - [x] 4. ~~Fix table alias syntax to use AS instead of triple underscore~~ (REMOVED - Not a core Sequel feature)
30
+
27
31
  - The `table___alias` syntax is not a core Sequel feature and requires an extension
28
32
  - Removed implementation and tests as this is not standard Sequel functionality
29
33
  - Standard Sequel table aliases use `.as()` method: `db[:users].as(:u)`
30
34
 
31
35
  - [x] 5. Fix qualified column references to use dot notation
36
+
32
37
  - Current issue: Qualified columns generate `users__id` instead of `users.id`
33
38
  - Override qualified identifier handling to generate proper dot notation
34
39
  - Implement `qualified_identifier_sql_append` method to use dot notation
@@ -37,6 +42,7 @@
37
42
  - _Requirements: 4.1, 4.2, 4.3, 4.4, 6.1, 6.2, 6.3, 6.4_
38
43
 
39
44
  - [x] 6. Fix SQL test infrastructure issues
45
+
40
46
  - Current issue: SQL tests failing with dataset type assertion errors (`Expected #<Sequel::Dataset::_Subclass>`)
41
47
  - Fix `SqlTest` class to use proper dataset creation instead of mock subclasses
42
48
  - Update SQL generation tests to work with actual DuckDB adapter behavior
@@ -45,6 +51,7 @@
45
51
  - _Requirements: 6.1, 6.2_
46
52
 
47
53
  - [x] 7. Fix recursive CTE SQL generation
54
+
48
55
  - Current issue: `WITH RECURSIVE` generates incorrect SQL without RECURSIVE keyword
49
56
  - Implement proper recursive CTE handling in dataset methods
50
57
  - Ensure recursive CTEs generate `WITH RECURSIVE` syntax correctly
@@ -52,6 +59,7 @@
52
59
  - _Requirements: 5.1, 5.2, 5.3, 5.4_
53
60
 
54
61
  - [x] 8. Fix JOIN USING clause generation
62
+
55
63
  - Current issue: `JOIN USING` clause not generating USING syntax correctly
56
64
  - Implement proper USING clause handling in JOIN operations
57
65
  - Ensure JOIN USING generates correct `INNER JOIN table USING (column)` syntax
@@ -59,6 +67,7 @@
59
67
  - _Requirements: 4.1, 4.2, 4.3, 4.4_
60
68
 
61
69
  - [x] 9. Fix regex functionality integration
70
+
62
71
  - Current issue: Regex matching returning 0 results instead of expected matches
63
72
  - Debug regex operator implementation in complex_expression_sql_append
64
73
  - Ensure regex patterns work correctly with DuckDB's regex syntax
@@ -66,6 +75,7 @@
66
75
  - _Requirements: 1.3, 5.1, 5.2, 5.3, 5.4_
67
76
 
68
77
  - [x] 10. Fix model integration issues
78
+
69
79
  - Current issue: Model tests failing with type mapping and update detection
70
80
  - Fix time type mapping (currently returning :datetime instead of :time)
71
81
  - Fix model update detection to properly track changed fields
@@ -73,6 +83,7 @@
73
83
  - _Requirements: 2.1, 2.2, 2.3, 2.4_
74
84
 
75
85
  - [x] 11. Fix table creation and schema issues
86
+
76
87
  - Current issue: Tests failing because tables don't exist during SQL execution
77
88
  - Ensure proper table creation in test setup for integration tests
78
89
  - Fix primary key handling for tables without explicit primary keys
@@ -80,6 +91,7 @@
80
91
  - _Requirements: 3.1, 3.2, 3.3, 3.4_
81
92
 
82
93
  - [x] 12. Verify all tests pass with consistent DuckDB SQL generation
94
+
83
95
  - Run complete test suite to ensure all SQL generation tests pass
84
96
  - Verify that adapter generates consistent, predictable SQL for DuckDB
85
97
  - Test integration scenarios to ensure functional correctness
@@ -87,6 +99,7 @@
87
99
  - _Requirements: 6.1, 6.2, 6.3, 6.4_
88
100
 
89
101
  - [x] 13. Document DuckDB-specific SQL syntax patterns
102
+
90
103
  - Document the specific SQL syntax that the adapter generates for DuckDB
91
104
  - Provide examples of DuckDB SQL patterns used by the adapter
92
105
  - Explain why certain DuckDB syntax choices were made
@@ -29,4 +29,4 @@ The sequel-duckdb adapter currently provides:
29
29
 
30
30
  No additional edge case or validation requirements have been identified that would add meaningful value to the adapter. The current implementation provides robust handling of edge cases appropriate for a production database adapter.
31
31
 
32
- This specification is considered complete with no outstanding requirements.
32
+ This specification is considered complete with no outstanding requirements.
@@ -114,4 +114,4 @@ This specification addresses database schema and setup issues in integration tes
114
114
  1. WHEN using test helpers THEN they SHALL work with the established database schema
115
115
  2. WHEN creating test data THEN helpers SHALL use the standardized fixtures
116
116
  3. WHEN verifying results THEN helpers SHALL understand the test database structure
117
- 4. WHEN cleaning up THEN helpers SHALL properly reset database state
117
+ 4. WHEN cleaning up THEN helpers SHALL properly reset database state