rails-sqlserver / activerecord-sqlserver-adapter

SQL Server Adapter For Rails
MIT License
968 stars 558 forks source link

Tracking rails/solid_cache compatibility #1122

Open jonahgeorge opened 8 months ago

jonahgeorge commented 8 months ago

With the announcement of rails/solid_cache at RailsWorld 2023, I wanted to see if it would work with activerecord-sqlserver-adapter... a few findings:

Usage of unique index on varbinary column

https://github.com/rails/solid_cache/blob/main/db/migrate/20230724121448_create_solid_cache_entries.rb#L8

ActiveRecord::StatementInvalid: TinyTds::Error: Column 'key' in table 'solid_cache_entries' is of a type that is invalid for use as a key column in an index.
/Users/jonahgeorge/src/solid_cache/test/dummy/db/schema.rb:14:in `block in <top (required)>'
/Users/jonahgeorge/src/solid_cache/test/dummy/db/schema.rb:13:in `<top (required)>'

Caused by:
TinyTds::Error: Column 'key' in table 'solid_cache_entries' is of a type that is invalid for use as a key column in an index.
/Users/jonahgeorge/src/solid_cache/test/dummy/db/schema.rb:14:in `block in <top (required)>'
/Users/jonahgeorge/src/solid_cache/test/dummy/db/schema.rb:13:in `<top (required)>'
Tasks: TOP => db:setup => app:db:setup => app:db:schema:load

This one seems fairly easy to resolve, an option in the upstream project to enable the usage of text fields rather than binary fields seems like something that could get accepted. AFAICT they're only using binary fields for minor performance gains.

Lack of upsert support

https://github.com/rails/solid_cache/blob/e4865809025d650736d818fce26d09737f6623b1/app/models/solid_cache/entry.rb#L74-L83

Error:
SolidCacheFailsafeTest#test_fetch_multi_failure_returns_fallback_results:
ArgumentError: ActiveRecord::ConnectionAdapters::SQLServerAdapter does not support upsert

Tracking Issue: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/859