sequel-duckdb 0.1.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 +7 -0
- data/.kiro/specs/advanced-sql-features-implementation/design.md +24 -0
- data/.kiro/specs/advanced-sql-features-implementation/requirements.md +43 -0
- data/.kiro/specs/advanced-sql-features-implementation/tasks.md +24 -0
- data/.kiro/specs/duckdb-sql-syntax-compatibility/design.md +258 -0
- data/.kiro/specs/duckdb-sql-syntax-compatibility/requirements.md +84 -0
- data/.kiro/specs/duckdb-sql-syntax-compatibility/tasks.md +94 -0
- data/.kiro/specs/edge-cases-and-validation-fixes/requirements.md +32 -0
- data/.kiro/specs/integration-test-database-setup/design.md +0 -0
- data/.kiro/specs/integration-test-database-setup/requirements.md +117 -0
- data/.kiro/specs/sequel-duckdb-adapter/design.md +542 -0
- data/.kiro/specs/sequel-duckdb-adapter/requirements.md +202 -0
- data/.kiro/specs/sequel-duckdb-adapter/tasks.md +247 -0
- data/.kiro/specs/sql-expression-handling-fix/design.md +298 -0
- data/.kiro/specs/sql-expression-handling-fix/requirements.md +86 -0
- data/.kiro/specs/sql-expression-handling-fix/tasks.md +22 -0
- data/.kiro/specs/test-infrastructure-improvements/requirements.md +106 -0
- data/.kiro/steering/product.md +22 -0
- data/.kiro/steering/structure.md +88 -0
- data/.kiro/steering/tech.md +124 -0
- data/.kiro/steering/testing.md +192 -0
- data/.rubocop.yml +103 -0
- data/.yardopts +8 -0
- data/API_DOCUMENTATION.md +919 -0
- data/CHANGELOG.md +131 -0
- data/LICENSE +21 -0
- data/MIGRATION_EXAMPLES.md +740 -0
- data/PERFORMANCE_OPTIMIZATIONS.md +723 -0
- data/README.md +692 -0
- data/Rakefile +27 -0
- data/TASK_10.2_IMPLEMENTATION_SUMMARY.md +164 -0
- data/docs/DUCKDB_SQL_PATTERNS.md +410 -0
- data/docs/TASK_12_VERIFICATION_SUMMARY.md +122 -0
- data/lib/sequel/adapters/duckdb.rb +256 -0
- data/lib/sequel/adapters/shared/duckdb.rb +2349 -0
- data/lib/sequel/duckdb/version.rb +16 -0
- data/lib/sequel/duckdb.rb +43 -0
- data/sig/sequel/duckdb.rbs +6 -0
- metadata +235 -0
@@ -0,0 +1,202 @@
|
|
1
|
+
# Requirements Document
|
2
|
+
|
3
|
+
## Introduction
|
4
|
+
|
5
|
+
This document outlines the requirements for building a complete Ruby Sequel database adapter for DuckDB. The adapter will enable Ruby applications to use DuckDB as a backend database through the Sequel ORM, providing full compatibility with Sequel's API and conventions. The implementation will follow the patterns established in existing Sequel adapters, with jeremyevans/sequel as the primary reference, sequel-hexspace as secondary reference for adapter structure, and sequel_impala as tertiary reference for implementation patterns, while leveraging the official ruby-duckdb gem for database connectivity.
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
### Requirement 1: Core Database Connectivity
|
10
|
+
|
11
|
+
**User Story:** As a Ruby developer, I want to connect to DuckDB databases using Sequel's standard connection interface, so that I can use DuckDB with existing Sequel-based applications.
|
12
|
+
|
13
|
+
#### Acceptance Criteria
|
14
|
+
|
15
|
+
1. WHEN a developer calls `Sequel.connect('duckdb://path/to/database.db')` THEN the system SHALL establish a connection to the specified DuckDB database file
|
16
|
+
2. WHEN a developer calls `Sequel.connect('duckdb::memory:')` THEN the system SHALL create an in-memory DuckDB database connection
|
17
|
+
3. WHEN connection parameters include additional options THEN the system SHALL pass those options to the underlying DuckDB connection
|
18
|
+
4. WHEN a connection fails THEN the system SHALL raise appropriate Sequel::DatabaseConnectionError exceptions
|
19
|
+
5. IF the DuckDB database file does not exist THEN the system SHALL create it automatically
|
20
|
+
6. WHEN the connection is closed THEN the system SHALL properly release all DuckDB resources
|
21
|
+
|
22
|
+
### Requirement 2: SQL Generation and Execution
|
23
|
+
|
24
|
+
**User Story:** As a Ruby developer, I want Sequel to generate DuckDB-compatible SQL statements, so that I can use Sequel's query interface without worrying about database-specific syntax.
|
25
|
+
|
26
|
+
#### Acceptance Criteria
|
27
|
+
|
28
|
+
1. WHEN Sequel generates SELECT statements THEN the system SHALL produce DuckDB-compatible SQL syntax
|
29
|
+
2. WHEN Sequel generates INSERT statements THEN the system SHALL handle DuckDB's specific insertion syntax and return value handling
|
30
|
+
3. WHEN Sequel generates UPDATE statements THEN the system SHALL generate proper DuckDB UPDATE syntax with appropriate WHERE clauses
|
31
|
+
4. WHEN Sequel generates DELETE statements THEN the system SHALL create valid DuckDB DELETE statements
|
32
|
+
5. WHEN Sequel generates DDL statements THEN the system SHALL produce DuckDB-compatible CREATE TABLE, ALTER TABLE, and DROP TABLE statements
|
33
|
+
6. WHEN complex queries with JOINs are generated THEN the system SHALL create proper DuckDB JOIN syntax
|
34
|
+
7. WHEN subqueries are used THEN the system SHALL generate nested SELECT statements compatible with DuckDB
|
35
|
+
8. WHEN aggregate functions are used THEN the system SHALL generate appropriate DuckDB aggregate syntax
|
36
|
+
|
37
|
+
### Requirement 3: Data Type Mapping
|
38
|
+
|
39
|
+
**User Story:** As a Ruby developer, I want Ruby data types to be automatically converted to appropriate DuckDB types and vice versa, so that I can work with native Ruby objects without manual type conversion.
|
40
|
+
|
41
|
+
#### Acceptance Criteria
|
42
|
+
|
43
|
+
1. WHEN Ruby String objects are stored THEN the system SHALL map them to DuckDB VARCHAR or TEXT types appropriately
|
44
|
+
2. WHEN Ruby Integer objects are stored THEN the system SHALL map them to appropriate DuckDB integer types (INTEGER, BIGINT)
|
45
|
+
3. WHEN Ruby Float objects are stored THEN the system SHALL map them to DuckDB DOUBLE or REAL types
|
46
|
+
4. WHEN Ruby Date objects are stored THEN the system SHALL map them to DuckDB DATE type
|
47
|
+
5. WHEN Ruby Time/DateTime objects are stored THEN the system SHALL map them to DuckDB TIMESTAMP type
|
48
|
+
6. WHEN Ruby Boolean objects are stored THEN the system SHALL map them to DuckDB BOOLEAN type
|
49
|
+
7. WHEN DuckDB values are retrieved THEN the system SHALL convert them back to appropriate Ruby types
|
50
|
+
8. WHEN NULL values are encountered THEN the system SHALL handle them as Ruby nil values
|
51
|
+
9. WHEN binary data is stored THEN the system SHALL map Ruby strings to DuckDB BLOB type appropriately
|
52
|
+
|
53
|
+
### Requirement 4: Schema Introspection
|
54
|
+
|
55
|
+
**User Story:** As a Ruby developer, I want Sequel to automatically discover and understand the structure of existing DuckDB databases, so that I can work with existing schemas without manual configuration.
|
56
|
+
|
57
|
+
#### Acceptance Criteria
|
58
|
+
|
59
|
+
1. WHEN `Database#tables` is called THEN the system SHALL return an array of all table names in the database
|
60
|
+
2. WHEN `Database#schema(table_name)` is called THEN the system SHALL return detailed column information including names, types, and constraints
|
61
|
+
3. WHEN table indexes exist THEN the system SHALL provide methods to introspect index information
|
62
|
+
4. WHEN foreign key relationships exist THEN the system SHALL detect and report foreign key constraints
|
63
|
+
5. WHEN primary keys are defined THEN the system SHALL identify primary key columns correctly
|
64
|
+
6. WHEN views exist in the database THEN the system SHALL list them separately from tables
|
65
|
+
7. WHEN column defaults are set THEN the system SHALL report the default values correctly
|
66
|
+
8. WHEN columns allow NULL THEN the system SHALL report the nullable status accurately
|
67
|
+
|
68
|
+
### Requirement 5: Transaction Support
|
69
|
+
|
70
|
+
**User Story:** As a Ruby developer, I want to use database transactions with DuckDB through Sequel's transaction interface, so that I can ensure data consistency and handle rollbacks.
|
71
|
+
|
72
|
+
#### Acceptance Criteria
|
73
|
+
|
74
|
+
1. WHEN `Database#transaction` is called THEN the system SHALL begin a DuckDB transaction
|
75
|
+
2. WHEN a transaction block completes successfully THEN the system SHALL commit the transaction automatically
|
76
|
+
3. WHEN an exception occurs within a transaction block THEN the system SHALL rollback the transaction
|
77
|
+
4. WHEN `Database#rollback` is called explicitly THEN the system SHALL rollback the current transaction
|
78
|
+
5. WHEN nested transactions are used THEN the system SHALL handle savepoints appropriately if DuckDB supports them
|
79
|
+
6. WHEN transaction isolation levels are specified THEN the system SHALL set them if supported by DuckDB
|
80
|
+
7. WHEN autocommit mode is disabled THEN the system SHALL handle manual transaction control properly
|
81
|
+
|
82
|
+
### Requirement 6: Dataset Operations
|
83
|
+
|
84
|
+
**User Story:** As a Ruby developer, I want to use Sequel's Dataset API to query and manipulate DuckDB data, so that I can leverage Sequel's powerful query building capabilities.
|
85
|
+
|
86
|
+
#### Acceptance Criteria
|
87
|
+
|
88
|
+
1. WHEN `Dataset#all` is called THEN the system SHALL return all matching records as Ruby hashes
|
89
|
+
2. WHEN `Dataset#first` is called THEN the system SHALL return the first matching record or nil
|
90
|
+
3. WHEN `Dataset#count` is called THEN the system SHALL return the number of matching records
|
91
|
+
4. WHEN `Dataset#where` is used THEN the system SHALL generate appropriate WHERE clauses for DuckDB
|
92
|
+
5. WHEN `Dataset#order` is used THEN the system SHALL generate proper ORDER BY clauses
|
93
|
+
6. WHEN `Dataset#limit` and `Dataset#offset` are used THEN the system SHALL generate DuckDB-compatible LIMIT/OFFSET syntax
|
94
|
+
7. WHEN `Dataset#group` is used THEN the system SHALL generate appropriate GROUP BY clauses
|
95
|
+
8. WHEN `Dataset#having` is used THEN the system SHALL generate proper HAVING clauses
|
96
|
+
9. WHEN `Dataset#join` methods are used THEN the system SHALL create appropriate JOIN statements
|
97
|
+
|
98
|
+
### Requirement 7: Model Integration
|
99
|
+
|
100
|
+
**User Story:** As a Ruby developer, I want to use Sequel::Model with DuckDB tables, so that I can use object-relational mapping features with DuckDB data.
|
101
|
+
|
102
|
+
#### Acceptance Criteria
|
103
|
+
|
104
|
+
1. WHEN a Sequel::Model is defined for a DuckDB table THEN the system SHALL automatically introspect the table schema
|
105
|
+
2. WHEN model instances are created THEN the system SHALL generate appropriate INSERT statements for DuckDB
|
106
|
+
3. WHEN model instances are updated THEN the system SHALL generate proper UPDATE statements
|
107
|
+
4. WHEN model instances are deleted THEN the system SHALL generate correct DELETE statements
|
108
|
+
5. WHEN model associations are defined THEN the system SHALL handle foreign key relationships properly
|
109
|
+
6. WHEN model validations are used THEN the system SHALL work correctly with DuckDB constraints
|
110
|
+
7. WHEN model callbacks are triggered THEN the system SHALL execute them at appropriate times during DuckDB operations
|
111
|
+
|
112
|
+
### Requirement 8: Error Handling and Logging
|
113
|
+
|
114
|
+
**User Story:** As a Ruby developer, I want clear error messages and proper logging when database operations fail, so that I can debug issues effectively.
|
115
|
+
|
116
|
+
#### Acceptance Criteria
|
117
|
+
|
118
|
+
1. WHEN DuckDB connection errors occur THEN the system SHALL raise Sequel::DatabaseConnectionError with descriptive messages
|
119
|
+
2. WHEN SQL syntax errors occur THEN the system SHALL raise Sequel::DatabaseError with the DuckDB error details
|
120
|
+
3. WHEN constraint violations occur THEN the system SHALL raise appropriate Sequel constraint error exceptions
|
121
|
+
4. WHEN SQL queries are executed THEN the system SHALL log them using Sequel's logging mechanism if enabled
|
122
|
+
5. WHEN database operations are slow THEN the system SHALL include timing information in logs
|
123
|
+
6. WHEN connection pooling errors occur THEN the system SHALL provide clear error messages
|
124
|
+
7. WHEN DuckDB-specific errors occur THEN the system SHALL map them to appropriate Sequel exception types
|
125
|
+
|
126
|
+
### Requirement 9: Performance Optimization
|
127
|
+
|
128
|
+
**User Story:** As a Ruby developer, I want the DuckDB adapter to perform efficiently with large datasets, so that my applications can handle production workloads effectively.
|
129
|
+
|
130
|
+
#### Acceptance Criteria
|
131
|
+
|
132
|
+
1. WHEN large result sets are fetched THEN the system SHALL use efficient row fetching mechanisms
|
133
|
+
2. WHEN prepared statements are beneficial THEN the system SHALL use DuckDB's prepared statement functionality
|
134
|
+
3. WHEN bulk inserts are performed THEN the system SHALL optimize for batch insertion performance
|
135
|
+
4. WHEN connection pooling is used THEN the system SHALL manage DuckDB connections efficiently
|
136
|
+
5. WHEN memory usage is a concern THEN the system SHALL provide streaming result options where possible
|
137
|
+
6. WHEN query plans are needed THEN the system SHALL provide access to DuckDB's EXPLAIN functionality
|
138
|
+
7. WHEN indexes are used THEN the system SHALL generate queries that can utilize DuckDB indexes effectively
|
139
|
+
|
140
|
+
### Requirement 10: Implementation Order and Structure
|
141
|
+
|
142
|
+
**User Story:** As a developer, I want the adapter implementation to follow a logical, incremental order based on proven patterns from sequel-hexspace, so that development can proceed systematically with testable milestones.
|
143
|
+
|
144
|
+
#### Acceptance Criteria
|
145
|
+
|
146
|
+
1. WHEN implementing the adapter THEN the system SHALL follow the implementation order: connection management, schema operations, basic SQL generation, advanced SQL features, DuckDB-specific features, and performance optimizations
|
147
|
+
2. WHEN organizing code THEN the system SHALL use the Sequel::DuckDB namespace following sequel-hexspace adapter pattern exactly
|
148
|
+
3. WHEN structuring files THEN the system SHALL place main adapter logic in lib/sequel/adapters/duckdb.rb and shared functionality in lib/sequel/adapters/shared/duckdb.rb following sequel-hexspace structure
|
149
|
+
4. WHEN implementing features THEN the system SHALL follow Test-Driven Development with comprehensive tests before implementation
|
150
|
+
5. WHEN adding functionality THEN the system SHALL implement in small, clearly defined, testable pieces
|
151
|
+
6. WHEN referencing patterns THEN the system SHALL study git history of sequel-hexspace for implementation guidance as primary reference
|
152
|
+
7. WHEN writing code THEN the system SHALL ensure all SQL generation has corresponding tests
|
153
|
+
8. WHEN developing THEN the system SHALL create thorough documentation for autonomous development
|
154
|
+
|
155
|
+
### Requirement 11: Testing and Quality Assurance (CRITICAL)
|
156
|
+
|
157
|
+
**User Story:** As a maintainer, I want comprehensive test coverage following sequel-hexspace testing patterns for all adapter functionality, so that I can ensure reliability and catch regressions.
|
158
|
+
|
159
|
+
#### Acceptance Criteria
|
160
|
+
|
161
|
+
1. WHEN any code is implemented THEN the system SHALL have tests written BEFORE the implementation (Test-Driven Development)
|
162
|
+
2. WHEN SQL generation methods are implemented THEN the system SHALL have unit tests verifying correct SQL output following sequel-hexspace test structure
|
163
|
+
3. WHEN database operations are implemented THEN the system SHALL have integration tests using actual DuckDB databases
|
164
|
+
4. WHEN data type conversions are implemented THEN the system SHALL have tests covering all supported type mappings
|
165
|
+
5. WHEN schema introspection is implemented THEN the system SHALL have tests verifying correct metadata retrieval
|
166
|
+
6. WHEN transaction handling is implemented THEN the system SHALL have tests covering commit, rollback, and error scenarios
|
167
|
+
7. WHEN error conditions occur THEN the system SHALL have tests verifying proper exception handling
|
168
|
+
8. WHEN performance-critical operations are implemented THEN the system SHALL have benchmarks to prevent regressions
|
169
|
+
9. WHEN test structure is organized THEN the system SHALL mirror sequel-hexspace test organization with test/all.rb, test/spec_helper.rb, test/database_test.rb, test/dataset_test.rb, test/schema_test.rb, test/prepared_statement_test.rb, test/sql_test.rb, and test/type_test.rb
|
170
|
+
10. WHEN mock database testing is needed THEN the system SHALL use Sequel's mock database functionality for SQL generation testing
|
171
|
+
11. WHEN integration testing is needed THEN the system SHALL use actual DuckDB in-memory databases for connection and operation testing
|
172
|
+
12. WHEN test coverage is measured THEN the system SHALL achieve 100% coverage of all implemented functionality
|
173
|
+
13. WHEN any task involves code implementation THEN the system SHALL create comprehensive tests as the first step of that task
|
174
|
+
|
175
|
+
### Requirement 12: Documentation and Examples
|
176
|
+
|
177
|
+
**User Story:** As a Ruby developer, I want clear documentation and examples for using the DuckDB adapter, so that I can integrate it into my applications quickly.
|
178
|
+
|
179
|
+
#### Acceptance Criteria
|
180
|
+
|
181
|
+
1. WHEN the gem is installed THEN the system SHALL provide a comprehensive README with usage examples
|
182
|
+
2. WHEN developers need API documentation THEN the system SHALL have complete YARD documentation for all public methods
|
183
|
+
3. WHEN developers need connection examples THEN the system SHALL provide sample connection strings and configurations
|
184
|
+
4. WHEN developers need migration examples THEN the system SHALL show how to use Sequel migrations with DuckDB
|
185
|
+
5. WHEN developers encounter common issues THEN the system SHALL provide troubleshooting documentation
|
186
|
+
6. WHEN performance tuning is needed THEN the system SHALL document DuckDB-specific optimization techniques
|
187
|
+
7. WHEN version compatibility is a concern THEN the system SHALL document supported Ruby and DuckDB versions
|
188
|
+
|
189
|
+
### Requirement 13: Compatibility and Standards
|
190
|
+
|
191
|
+
**User Story:** As a Ruby developer, I want the DuckDB adapter to follow Sequel conventions and Ruby best practices exactly like sequel-hexspace, so that it integrates seamlessly with existing codebases.
|
192
|
+
|
193
|
+
#### Acceptance Criteria
|
194
|
+
|
195
|
+
1. WHEN the adapter is loaded THEN the system SHALL follow Sequel's adapter loading conventions using the Sequel::DuckDB namespace exactly like sequel-hexspace
|
196
|
+
2. WHEN code is written THEN the system SHALL adhere to jeremyevans/sequel coding standards and RuboCop configuration with double quotes for string literals
|
197
|
+
3. WHEN exceptions are raised THEN the system SHALL use Sequel's standard exception hierarchy
|
198
|
+
4. WHEN configuration options are provided THEN the system SHALL follow Sequel's configuration patterns
|
199
|
+
5. WHEN the gem is packaged THEN the system SHALL follow Ruby gem conventions with standard structure (Gemfile, Rakefile, .rubocop.yml)
|
200
|
+
6. WHEN dependencies are specified THEN the system SHALL use ruby-duckdb gem exclusively for database connections with appropriate version constraints
|
201
|
+
7. WHEN Ruby versions are supported THEN the system SHALL maintain compatibility with Ruby 3.1+ as specified in the technology requirements
|
202
|
+
8. WHEN file structure is organized THEN the system SHALL place adapter logic in lib/sequel/adapters/duckdb.rb and shared functionality in lib/sequel/adapters/shared/duckdb.rb following sequel-hexspace conventions exactly
|
@@ -0,0 +1,247 @@
|
|
1
|
+
# Implementation Plan
|
2
|
+
|
3
|
+
- [x] 1. Set up project structure following sequel-hexspace pattern
|
4
|
+
- Create lib/sequel/adapters/duckdb.rb for main Database and Dataset classes
|
5
|
+
- Create lib/sequel/adapters/shared/duckdb.rb for DatabaseMethods and DatasetMethods modules
|
6
|
+
- Set up proper require structure and module organization
|
7
|
+
- _Requirements: 10.3, 13.8_
|
8
|
+
|
9
|
+
- [x] 2. Implement basic connection management in shared module
|
10
|
+
- [x] 2.1 Create DatabaseMethods module with connection handling
|
11
|
+
- Implement connect method for file and in-memory databases
|
12
|
+
- Implement disconnect_connection and valid_connection? methods
|
13
|
+
- Add proper error handling for connection failures
|
14
|
+
- _Requirements: 1.1, 1.2, 1.4, 1.6_
|
15
|
+
|
16
|
+
- [x] 2.2 Create Database class with adapter registration
|
17
|
+
- Define Sequel::DuckDB::Database class including DatabaseMethods
|
18
|
+
- Set adapter scheme to :duckdb
|
19
|
+
- Implement dataset_class_default method
|
20
|
+
- Register adapter with Sequel
|
21
|
+
- _Requirements: 1.1, 10.2, 13.1_
|
22
|
+
|
23
|
+
- [x] 2.3 Fix adapter registration (CRITICAL BUG)
|
24
|
+
- Fix incorrect adapter registration in lib/sequel/adapters/duckdb.rb
|
25
|
+
- Change from `Sequel::Database.set_shared_adapter_scheme :duckdb, self` to proper registration
|
26
|
+
- Use `Database.adapter_scheme :duckdb, DuckDB::Database` pattern
|
27
|
+
- _Requirements: 1.1, 13.1_
|
28
|
+
|
29
|
+
- [x] 3. Set up comprehensive test infrastructure (CRITICAL - TDD REQUIREMENT)
|
30
|
+
- [x] 3.1 Create test infrastructure following sequel-hexspace pattern
|
31
|
+
- Create test/all.rb test runner
|
32
|
+
- Create test/spec_helper.rb with test configuration and DuckDB setup
|
33
|
+
- Set up test database helpers and utilities for both mock and real DuckDB testing
|
34
|
+
- Configure test environment with proper require statements
|
35
|
+
- _Requirements: 11.8, 10.4, 13.1_
|
36
|
+
|
37
|
+
- [x] 3.2 Create core test files with initial structure
|
38
|
+
- Create test/database_test.rb for connection and basic functionality tests
|
39
|
+
- Create test/dataset_test.rb for comprehensive SQL generation testing
|
40
|
+
- Create test/schema_test.rb for schema operations and introspection
|
41
|
+
- Create test/sql_test.rb for SQL generation and syntax verification
|
42
|
+
- Create test/type_test.rb for data type handling and conversion
|
43
|
+
- _Requirements: 11.1, 11.2, 11.4, 11.3_
|
44
|
+
|
45
|
+
- [x] 4. Implement basic SQL generation in shared module (TDD - TESTS FIRST)
|
46
|
+
- [x] 4.1 Write tests for core SQL generation methods
|
47
|
+
- Write comprehensive tests for select_sql method using mock database
|
48
|
+
- Write tests for insert_sql method with various parameter combinations
|
49
|
+
- Write tests for update_sql method with WHERE clauses
|
50
|
+
- Write tests for delete_sql method with conditions
|
51
|
+
- Ensure all tests fail initially (Red phase of TDD)
|
52
|
+
- _Requirements: 2.1, 2.2, 2.3, 2.4, 11.1, 11.2_
|
53
|
+
|
54
|
+
- [x] 4.2 Implement DatasetMethods module with core SQL generation
|
55
|
+
- Implement select_sql method for basic SELECT statements
|
56
|
+
- Implement insert_sql method for INSERT operations
|
57
|
+
- Implement update_sql method for UPDATE operations
|
58
|
+
- Implement delete_sql method for DELETE operations
|
59
|
+
- Ensure all tests pass (Green phase of TDD)
|
60
|
+
- _Requirements: 2.1, 2.2, 2.3, 2.4_
|
61
|
+
|
62
|
+
- [x] 4.3 Write tests for Dataset class functionality
|
63
|
+
- Write tests for fetch_rows method using real DuckDB in-memory database
|
64
|
+
- Write tests for DuckDB capability flags (window functions, CTE support, etc.)
|
65
|
+
- Write integration tests for basic query execution
|
66
|
+
- _Requirements: 2.1, 6.1, 6.2, 11.3_
|
67
|
+
|
68
|
+
- [x] 4.4 Implement Dataset class with shared functionality
|
69
|
+
- Implement fetch_rows method for query execution
|
70
|
+
- Add DuckDB capability flags (window functions, CTE support, etc.)
|
71
|
+
- Ensure proper integration with DatabaseMethods
|
72
|
+
- _Requirements: 2.1, 6.1, 6.2_
|
73
|
+
|
74
|
+
- [x] 5. Implement data type handling and literal conversion (TDD - TESTS FIRST)
|
75
|
+
- [x] 5.1 Write tests for literal conversion methods
|
76
|
+
- Write tests for literal_string_append with string escaping scenarios
|
77
|
+
- Write tests for literal_date, literal_datetime, literal_time methods
|
78
|
+
- Write tests for literal_boolean method with true/false values
|
79
|
+
- Write tests for NULL value handling and edge cases
|
80
|
+
- _Requirements: 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.8, 11.4_
|
81
|
+
|
82
|
+
- [x] 5.2 Add literal conversion methods to DatasetMethods
|
83
|
+
- Implement literal_string_append for string escaping
|
84
|
+
- Implement literal_date, literal_datetime, literal_time methods
|
85
|
+
- Implement literal_boolean method for boolean values
|
86
|
+
- Add support for NULL value handling
|
87
|
+
- _Requirements: 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.8_
|
88
|
+
|
89
|
+
- [x] 5.3 Write tests for binary data and numeric type support
|
90
|
+
- Write tests for BLOB type mapping for binary data
|
91
|
+
- Write tests for integer and float type handling
|
92
|
+
- Write tests for Ruby to DuckDB type conversion edge cases
|
93
|
+
- _Requirements: 3.2, 3.3, 3.9, 11.4_
|
94
|
+
|
95
|
+
- [x] 5.4 Add binary data and numeric type support
|
96
|
+
- Implement BLOB type mapping for binary data
|
97
|
+
- Add proper integer and float type handling
|
98
|
+
- Ensure proper Ruby to DuckDB type conversion
|
99
|
+
- _Requirements: 3.2, 3.3, 3.9_
|
100
|
+
|
101
|
+
- [-] 6. Implement schema introspection in DatabaseMethods (TDD - TESTS FIRST)
|
102
|
+
- [x] 6.1 Write tests for schema introspection methods
|
103
|
+
- Write tests for schema_parse_tables method for table listing
|
104
|
+
- Write tests for schema_parse_table method for column information
|
105
|
+
- Write tests for schema_parse_indexes method for index introspection
|
106
|
+
- Write tests for views and foreign key detection
|
107
|
+
- _Requirements: 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 11.5_
|
108
|
+
|
109
|
+
- [x] 6.2 Add table and schema discovery methods
|
110
|
+
- Implement schema_parse_tables method for table listing
|
111
|
+
- Implement schema_parse_table method for column information
|
112
|
+
- Implement schema_parse_indexes method for index introspection
|
113
|
+
- Add support for views and foreign key detection
|
114
|
+
- _Requirements: 4.1, 4.2, 4.3, 4.4, 4.5, 4.6_
|
115
|
+
|
116
|
+
- [x] 6.3 Write tests for schema metadata methods
|
117
|
+
- Write tests for tables method using schema_parse_tables
|
118
|
+
- Write tests for schema method using schema_parse_table
|
119
|
+
- Write tests for indexes method using schema_parse_indexes
|
120
|
+
- Write tests for column default and nullable status reporting
|
121
|
+
- _Requirements: 4.7, 4.8, 11.5_
|
122
|
+
|
123
|
+
- [x] 6.4 Add schema metadata methods
|
124
|
+
- Implement tables method using schema_parse_tables
|
125
|
+
- Implement schema method using schema_parse_table
|
126
|
+
- Implement indexes method using schema_parse_indexes
|
127
|
+
- Add proper column default and nullable status reporting
|
128
|
+
- _Requirements: 4.7, 4.8_
|
129
|
+
|
130
|
+
- [-] 7. Implement transaction support in DatabaseMethods
|
131
|
+
- [x] 7.1 Add basic transaction methods
|
132
|
+
- Implement transaction block handling
|
133
|
+
- Add automatic commit on successful completion
|
134
|
+
- Add automatic rollback on exceptions
|
135
|
+
- Implement explicit rollback method
|
136
|
+
- _Requirements: 5.1, 5.2, 5.3, 5.4_
|
137
|
+
|
138
|
+
- [x] 6.2 Add advanced transaction features
|
139
|
+
- Implement savepoint support if available in DuckDB
|
140
|
+
- Add transaction isolation level support
|
141
|
+
- Implement manual transaction control for autocommit mode
|
142
|
+
- _Requirements: 5.5, 5.6, 5.7_
|
143
|
+
|
144
|
+
- [x] 8. Implement advanced SQL generation features
|
145
|
+
- [x] 8.1 Add complex query support to DatasetMethods
|
146
|
+
- Implement proper WHERE clause generation
|
147
|
+
- Add ORDER BY, LIMIT, and OFFSET support
|
148
|
+
- Implement GROUP BY and HAVING clause generation
|
149
|
+
- Add JOIN statement generation
|
150
|
+
- _Requirements: 6.4, 6.5, 6.6, 6.7, 6.8, 6.9_
|
151
|
+
|
152
|
+
- [x] 8.2 Add DuckDB-specific SQL features
|
153
|
+
- Implement window function support
|
154
|
+
- Add Common Table Expression (CTE) support
|
155
|
+
- Implement subquery generation
|
156
|
+
- Add aggregate function support
|
157
|
+
- _Requirements: 2.6, 2.7, 2.8_
|
158
|
+
|
159
|
+
- [x] 9. Implement SQL execution methods in DatabaseMethods
|
160
|
+
- [x] 9.1 Add core SQL execution methods
|
161
|
+
- Implement execute method with connection synchronization
|
162
|
+
- Implement execute_insert and execute_update methods
|
163
|
+
- Add execute_statement private method for actual SQL execution
|
164
|
+
- Implement proper result handling and iteration
|
165
|
+
- _Requirements: 2.1, 2.2, 2.3, 2.4_
|
166
|
+
|
167
|
+
- [x] 9.2 Add dataset operation support
|
168
|
+
- Implement count, first, and all methods in DatasetMethods
|
169
|
+
- Add proper result set handling and conversion
|
170
|
+
- Implement streaming result support where possible
|
171
|
+
- _Requirements: 6.1, 6.2, 6.3, 9.5_
|
172
|
+
|
173
|
+
- [-] 10. Implement error handling and logging
|
174
|
+
- [x] 10.1 Add error mapping in DatabaseMethods
|
175
|
+
- Implement database_error_classes method
|
176
|
+
- Add database_exception_sqlstate method for SQL state extraction
|
177
|
+
- Map DuckDB errors to appropriate Sequel exceptions
|
178
|
+
- Implement proper constraint violation error handling
|
179
|
+
- _Requirements: 8.1, 8.2, 8.3, 8.7_
|
180
|
+
|
181
|
+
- [x] 9.2 Add logging and debugging support
|
182
|
+
- Implement SQL query logging using Sequel's logging mechanism
|
183
|
+
- Add timing information for slow operations
|
184
|
+
- Implement connection pooling error handling
|
185
|
+
- Add EXPLAIN functionality access for query plans
|
186
|
+
- _Requirements: 8.4, 8.5, 8.6, 9.6_
|
187
|
+
|
188
|
+
- [x] 11. Implement performance optimizations
|
189
|
+
- [x] 11.1 Add efficient result fetching
|
190
|
+
- Optimize fetch_rows method for large result sets
|
191
|
+
- Implement prepared statement support if beneficial
|
192
|
+
- Add bulk insert optimization methods
|
193
|
+
- Implement efficient connection pooling
|
194
|
+
- _Requirements: 9.1, 9.2, 9.3, 9.4_
|
195
|
+
|
196
|
+
- [x] 10.2 Add memory and query optimizations
|
197
|
+
- Implement streaming result options for memory efficiency
|
198
|
+
- Add index-aware query generation
|
199
|
+
- Optimize for DuckDB's columnar storage advantages
|
200
|
+
- Implement parallel query execution support
|
201
|
+
- _Requirements: 9.5, 9.7_
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
- [x] 12. Implement Sequel::Model integration support
|
206
|
+
- [x] 12.1 Add model compatibility methods
|
207
|
+
- Ensure automatic schema introspection works with models
|
208
|
+
- Implement proper INSERT statement generation for model creation
|
209
|
+
- Add UPDATE statement generation for model updates
|
210
|
+
- Implement DELETE statement generation for model deletion
|
211
|
+
- _Requirements: 7.1, 7.2, 7.3, 7.4_
|
212
|
+
|
213
|
+
- [x] 12.2 Add association and validation support
|
214
|
+
- Implement foreign key relationship handling for associations
|
215
|
+
- Ensure model validations work correctly with DuckDB constraints
|
216
|
+
- Add model callback support during DuckDB operations
|
217
|
+
- _Requirements: 7.5, 7.6, 7.7_
|
218
|
+
|
219
|
+
- [x] 13. Create documentation and examples
|
220
|
+
- [x] 13.1 Write comprehensive README
|
221
|
+
- Create usage examples with connection strings
|
222
|
+
- Add sample code for common operations
|
223
|
+
- Document DuckDB-specific features and optimizations
|
224
|
+
- Include troubleshooting section for common issues
|
225
|
+
- _Requirements: 12.1, 12.2, 12.5_
|
226
|
+
|
227
|
+
- [x] 13.2 Add API documentation and migration examples
|
228
|
+
- Generate complete YARD documentation for all public methods
|
229
|
+
- Create Sequel migration examples for DuckDB
|
230
|
+
- Document performance tuning techniques
|
231
|
+
- Add version compatibility documentation
|
232
|
+
- _Requirements: 12.2, 12.3, 12.4, 12.6_
|
233
|
+
|
234
|
+
- [x] 14. Final integration and compatibility verification
|
235
|
+
- [x] 14.1 Verify Sequel conventions compliance
|
236
|
+
- Ensure adapter follows Sequel's standard exception hierarchy
|
237
|
+
- Verify configuration options follow Sequel patterns
|
238
|
+
- Test compatibility with Ruby 3.1+ requirements
|
239
|
+
- Validate gem packaging follows Ruby conventions
|
240
|
+
- _Requirements: 13.2, 13.3, 13.4, 13.5, 13.7_
|
241
|
+
|
242
|
+
- [x] 14.2 Complete end-to-end testing
|
243
|
+
- Run comprehensive test suite with real DuckDB databases
|
244
|
+
- Verify all SQL generation produces valid DuckDB syntax
|
245
|
+
- Test performance with large datasets
|
246
|
+
- Validate memory usage and connection handling
|
247
|
+
- _Requirements: 11.7, 9.1, 9.4, 9.5_
|