Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres store with array with hstore #647

Closed
simonykq opened this issue May 7, 2015 · 0 comments
Closed

Postgres store with array with hstore #647

simonykq opened this issue May 7, 2015 · 0 comments

Comments

@simonykq
Copy link

simonykq commented May 7, 2015

Hi,

I have a Jruby on Rails app which use activerecord-jdbc-adaptor to store data in Postgres. I have the following schema definition:

    enable_extension 'hstore' unless extension_enabled?('hstore')
    create_table :preprocessor_results do |t|
      t.hstore :retained_fields, array: true
    end

How ever, when I run following:

   PreprocessorResult.create(retained_fields: [{a: 'a'},{b: 'b'}])

It returns the following error messages:

ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: malformed array literal: "{"a"=>"a","b"=>"b"}"
  Position: 64: INSERT INTO "preprocessor_results" ("retained_fields") VALUES ('{"a"=>"a","b"=>"b"}') RETURNING "id"
    from arjdbc/jdbc/RubyJdbcConnection.java:848:in `execute_query'

Found in activerecord-jdbc-adaptor version 1.3.16, activerecord version 4.1.10 and my Rails version is 4.1.10

I googled this issue and it said that this issues was fixed on Rails 4.1 onward. Not sure why I got this. The only difference is I use jRuby rather than MRI ruby. So I guess here would probably be where I should raise the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants