Skip to content

Prepared statement error on varchar array columns #371

@shaunma

Description

@shaunma

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.

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:

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:
#<ActiveRecord::StatementInvalid:"PG::IndeterminateDatatype: ERROR: could not determine data type of placeholder $1\nHINT: consider adding explicit type casts to the placeholder arguments\n">

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions