cockroachdb / cockroachdb/activerecord-cockroachdb-adapter

Prepared statement error on varchar array columns

Open
#371 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
105
Forks
56
Avg merge
9h 5m
Merged PRs (30d)
3

Description

Version 7.2 of the adapter seems to reject `? = ANY(array_column)` queries.

### Steps to Reproduce:

Install and run CockroachDB v25.1.2 locally.
Create a Rails application using the following packages.
```ruby
gem 'activerecord-cockroachdb-adapter', '~> 7.2'
gem 'rails', '~> 7.2.2'
```

Create a table containing a column containing a string array using the following script:
```ruby
class AddUsers < ActiveRecord::Migration[7.2]
def change
create_table :users do |t|
t.string :languages, array: true
end
end
end
```

Complete the migration. Open Rails console and run: `User.where('? = ANY(languages)', 'en')`.

This error is raised:
`#`

I am able to run `select * from users where 'en' = ANY (languages)` directly in CockroachDB, so I think that the error is caused by the driver.

The same statement runs without issues on Postgres 12.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue in a Rails console with CockroachDB 25.1.2 and the documented User.where('? = ANY(languages)', 'en') query, then compare it with the direct SQL and PostgreSQL 12 behavior. Done means the prepared statement works for varchar array columns without the reported indeterminate-placeholder-type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.