Skip to content

Feature/add test suite#7

Open
eddietejeda wants to merge 3 commits intored-data-tools:mainfrom
eddietejeda:feature/add-test-suite
Open

Feature/add test suite#7
eddietejeda wants to merge 3 commits intored-data-tools:mainfrom
eddietejeda:feature/add-test-suite

Conversation

@eddietejeda
Copy link
Copy Markdown

Add test suite and CI configuration

  • Add test suite structured so that you can run bundle exec rake test
  • Add functional, integration, and unit tests with some tests stubbed out for future reference
  • Add CI workflow configuration for automated testing

- Update database_statements.rb transaction support and query execution, default to using @raw_connection, and add support for binding params
- Add schema_statements.rb DDL operations (CREATE/ALTER/DROP table support)
- BREAKING: Remove legacy Railtie approach and use modern ActiveRecord::ConnectionAdapters.register approach for registering gem
- Add YARD documentation to make it clear which files were implementing necessary methods
- Default to writing DuckDB file to disk
- Validated lifecycle of creating and deploying databases and tested bundle exec rails db:drop db:create db:migrate db:seed db:reset
- Use DuckDB's information_schema for accessing meta data
- Default primary ids as bigints
- Add quoting.rb for proper SQL quoting and escaping
- Add explain_pretty_printer.rb for formatted EXPLAIN output
- Add tasks.rb for Rails database tasks (db:create, db:drop, etc.)
- Add test suite structured so that you can run bundle exec rake test
- Add functional, integration, and unit tests with some tests stubbed out for future reference
- Add CI workflow configuration for automated testing
nicosuave pushed a commit to nicosuave/activerecord-duckdb-adapter that referenced this pull request Dec 5, 2025
### Summary of Changes

This pull request introduces support for the `time` data type when using
the SQLite backend. The ADBC SQLite driver does not natively support a
`time` type, so this change implements a workaround by quoting `Time`
objects as strings, which is consistent with how Rails' built-in SQLite3
adapter handles them.

The changes include:
- **Quoting:** A `quoted_time` method has been added to `quoting.rb`.
For the SQLite backend, it delegates to Rails' internal
`SQLite3::Quoting` module to ensure the time is formatted into the
standard `2000-01-01 HH:MM:SS.SSSSSS` string format.
- **Result Set Conversion:** The `Result` class in `result.rb` now
correctly converts these time strings back into an `Arrow::Time64Array`
when processing query results for a model.
- **Testing:** The `Time` type tests in `test_type.rb`, which were
previously omitted for SQLite, are now enabled and passing.

### Reason for Changes

Without this change, using `ActiveRecord::Type::Time` with the SQLite
backend would fail because the ADBC driver lacks native support for this
data type. This implementation bridges the gap by adopting the same
string-based serialization strategy used by the standard Rails SQLite3
adapter, enabling seamless use of the `time` type.

### Affected Components

- `lib/activerecord_adbc_adapter/quoting.rb`
- `lib/activerecord_adbc_adapter/result.rb`
- `test/test_type.rb`

### Testing

The existing tests for the `time` type in `test/test_type.rb` now run
successfully against the SQLite backend.

To verify:
1. Set the backend to SQLite.
2. Run the test suite, specifically `test_time_active_record` and
`test_time_arrow`.
   ```bash
       bundle exec ruby test/run.rb -n /test_time/
   ```
All tests related to the Time type should pass.

### Related issue
red-data-tools#7

---------

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant