tlconnor / activerecord-postgres-array Goto Github PK
View Code? Open in Web Editor NEWPostgres array support for Active Record
License: ISC License
Postgres array support for Active Record
License: ISC License
Any idea?
Whenever I try to use schema.rb with integer_array fields, I get an error:
NOTICE: CREATE TABLE will create implicit sequence "analytic_logs_id_seq" for serial column "analytic_logs.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "analytic_logs_pkey" for table "analytic_logs"
NOTICE: CREATE TABLE will create implicit sequence "educations_id_seq" for serial column "educations.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "educations_pkey" for table "educations"
NOTICE: CREATE TABLE will create implicit sequence "jobs_id_seq" for serial column "jobs.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "jobs_pkey" for table "jobs"
rake aborted!
PG::Error: ERROR: syntax error at or near "{"
LINE 1: ...ly_to" integer, "recipient_ids" integer[] DEFAULT {}, "read_...
^
: CREATE TABLE "messages" ("id" serial primary key, "body" text NOT NULL, "is_active" boolean DEFAULT 't', "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL, "type" character varying(255), "sender_id" integer, "initiator_id" integer, "is_welcome_message" boolean DEFAULT 'f', "need_text" text, "need_keywords" text, "reply_hash" character varying(255), "provider" character varying(255), "in_reply_to" integer, "recipient_ids" integer[] DEFAULT {}, "read_ids" integer[] DEFAULT {})
I have a number of string array fields that have the same empty default and they are fine. Here is schema.rb:
t.integer "in_reply_to"
t.integer_array "recipient_ids", :default => "{}"
t.integer_array "read_ids", :default => "{}"
I noticed that when I set this line:
config.active_record.schema_format = :sql
to be :sql, it works ok. However, that has negative side effects with rspec rake tasks, that I'd like to avoid if possible.
Any idea why it won't take defaults with integer arrays and make use of schema.rb?
I have this in my migration:
t.string_array :roles, :default => '{}'
but, when a try to run the migration a receive this erro message:
PG::SyntaxError: ERROR: syntax error at or near "{"
LINE 1: ...integer, "roles" character varying(255)[] DEFAULT {}, "creat..
So.. how can I use default values ?
I'm using postgres 9.1 and Rails 3.2.13
Hi, it seems that this gem is interfering with the regular YAML serialization code in AR. If I include this gem in my Gemfile, I'm unable to create a new record for a model which has a YAML-serialized column, irrespective of whether it has an attribute which maps to a postgres-array column or not.
I tried the same with the ar_pg_array
gem but it doesn't have this problem.
Here's the error message I get:
NoMethodError: undefined method `serialized_value' for nil:NilClass
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activesupport-3.1.1/lib/active_support/whiny_nil.rb:48:in `method_missing'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-postgres-array-0.0.8/lib/activerecord-postgres-array/activerecord.rb:22:in `block in arel_attributes_values'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-postgres-array-0.0.8/lib/activerecord-postgres-array/activerecord.rb:13:in `each'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-postgres-array-0.0.8/lib/activerecord-postgres-array/activerecord.rb:13:in `arel_attributes_values'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/persistence.rb:311:in `create'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/timestamp.rb:51:in `create'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/callbacks.rb:268:in `block in create'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:390:in `_run_create_callbacks'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/callbacks.rb:268:in `create'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/persistence.rb:294:in `create_or_update'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/callbacks.rb:264:in `block in create_or_update'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:426:in `_run_save_callbacks'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/callbacks.rb:264:in `create_or_update'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/persistence.rb:37:in `save'
... 1 levels...
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/attribute_methods/dirty.rb:22:in `save'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/transactions.rb:208:in `transaction'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/transactions.rb:241:in `block in save'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/transactions.rb:240:in `save'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/activerecord-3.1.1/lib/active_record/base.rb:510:in `create'
from (irb):1
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in `start'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in `start'
from /Users/saurabhnanda/.rvm/gems/ruby-1.9.3-p125@g/gems/railties-3.1.1/lib/rails/commands.rb:40:in `<top (required)>'
from ./script/rails:6:in `require'
I have the following data in a field skills
:
{Networking,"Network Security","High distributed Applications","Web Application Development.","Programming: C",C++,"Core Java","J2EE Platform",Jquery,Javascript,PHP,"Objective C","Visual Studio",Cocoa,"Android.
Web: Ajax",JSON,Xquery,XML,HTML,CSS,"Apache.
Scripting: Python",Perl,Shell,"php.
Database: mySQL","Oracle 9i",Oracle10g,"Sqlite.
MVC Framework: Java Struts 2.0",Velocity,"Django.
Development Tools: gcc",gdb,"Eclipse IDE",emacs,Xcode,"tshark.
Interests: Systems","Cloud Computing",Algorithms,"Web Technologies and Development","Mobile Development.",JAVA,"C programming","C++ programming",Python,Django,SQL,"Jquery / Javascript","PHP development",Apache,"XML Schema",XQuery,"Oracle Spatial",Android,AJAX,MVC,"J2EE Architecture","Network Programming","Web Development",Japanese,"Distributed Systems",Objective-C,VPN,"VPN Protocols","Computer Software"}
When accessing the array user.skills
I get the following error:
irb(main):097:0> u.skills
NoMethodError: undefined method `captures' for nil:NilClass
from /Users/bhilkert/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-postgres-array-0.0.7/lib/activerecord-postgres-array/string.rb:23:in `from_postgres_array'
Following the code, it seems match(/\{(.*)\}/) => nil
and therefore blows up when sending captures
on it. I'm a little baffled what's different about this field and have tried taking out certain characters with no luck.
Let me know if I'm missing something obvious.
I've been trying to dig into what's happening, but I'm at a road block. Any help would be greatly appreciated!
I'm appending and saving multiple email objects, which have two attributes utilizing the string_array data type, to a has_many relationship.
This is the stack trace:
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-postgres-array-0.0.6/lib/activerecord-postgres-array/string.rb:23:in from_postgres_array' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.3/lib/active_support/multibyte/chars.rb:59:in
method_missing'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/attribute_methods/read.rb:82:in __temp__' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/attribute_methods/read.rb:46:in
type_cast_attribute'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/attribute_methods/read.rb:126:in read_attribute' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-postgres-array-0.0.6/lib/activerecord-postgres-array/activerecord.rb:16:in
block in arel_attributes_values'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-postgres-array-0.0.6/lib/activerecord-postgres-array/activerecord.rb:13:in each' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-postgres-array-0.0.6/lib/activerecord-postgres-array/activerecord.rb:13:in
arel_attributes_values'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/persistence.rb:361:in create' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/timestamp.rb:57:in
create'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/callbacks.rb:268:in block in create' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:403:in
_run__857705358352641404__create__3650861947297733372__callbacks'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in __run_callback' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in
_run_create_callbacks'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in run_callbacks' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/callbacks.rb:268:in
create'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/persistence.rb:344:in create_or_update' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/callbacks.rb:264:in
block in create_or_update'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:414:in _run__857705358352641404__save__3650861947297733372__callbacks' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in
__run_callback'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in _run_save_callbacks' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in
run_callbacks'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/callbacks.rb:264:in create_or_update' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/persistence.rb:84:in
save'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/validations.rb:50:in save' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/attribute_methods/dirty.rb:22:in
save'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/transactions.rb:241:in block (2 levels) in save' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/transactions.rb:295:in
block in with_transaction_returning_status'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in transaction' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/transactions.rb:208:in
transaction'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/transactions.rb:293:in with_transaction_returning_status' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/transactions.rb:241:in
block in save'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/transactions.rb:252:in rollback_active_record_state!' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/transactions.rb:240:in
save'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/has_many_association.rb:16:in insert_record' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:492:in
block (2 levels) in concat_records'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:342:in add_to_target' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:491:in
block in concat_records'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:489:in each' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:489:in
concat_records'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:134:in block in concat' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:149:in
block in transaction'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in transaction' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/transactions.rb:208:in
transaction'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:148:in transaction' /Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/collection_association.rb:134:in
concat'
/Users/davidkpham/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.3/lib/active_record/associations/collection_proxy.rb:116:in <<' /Users/davidkpham/Dropbox/Spectacle/Product/Code/Web application/mosec/app/models/email_account.rb:140:in
block (3 levels) in index_emails'
/Users/davidkpham/Dropbox/Spectacle/Product/Code/Web application/mosec/app/models/email_account.rb:130:in each' /Users/davidkpham/Dropbox/Spectacle/Product/Code/Web application/mosec/app/models/email_account.rb:130:in
block (2 levels) in index_emails'
/Users/davidkpham/Dropbox/Spectacle/Product/Code/Web application/mosec/app/models/email_account.rb:127:in each' /Users/davidkpham/Dropbox/Spectacle/Product/Code/Web application/mosec/app/models/email_account.rb:127:in
each_slice'
/Users/davidkpham/Dropbox/Spectacle/Product/Code/Web application/mosec/app/models/email_account.rb:127:in block in index_emails' /Users/davidkpham/Dropbox/Spectacle/Product/Code/Web application/mosec/app/models/email_account.rb:122:in
each'
/Users/davidkpham/Dropbox/Spectacle/Product/Code/Web application/mosec/app/models/email_account.rb:122:in index_emails' /Users/davidkpham/Dropbox/Spectacle/Product/Code/Web application/mosec/app/jobs/emails_synchronizer.rb:8:in
perform'
Excuse me for being noisy.
How it differs from my gem https://github.com/funny-falcon/activerecord-postgresql-arrays ? Why you decided to start new one?
I know supporting arel-type query constructs is mentioned in your future enhancements, but would it be possible to give me some pointers on how to get the following working WITHOUT resorting to string-based SQL fragments?
clause = clause.or(Arel::Nodes::NamedFunction.new('any', [Post.arel_table[:tags]]).eq(tag))
So I ran into this issue after upgrading to the latest version of activerecord-postgres-hstore
diogob/activerecord-postgres-hstore@ca34391
It seems that commit makes
elsif defined?(::Hstore) && column.type == :hstore && value && value.is_a?(Hash)
value = value.to_hstore
execute and since they removed to_hstore
in version 0.7.0 it throws a undefined method 'to_hstore' for {}:Hash
(a) I've created a table with a decimal_array
(which maps to PG's numeric[]
). However, rake is not refusing to dump it in schema.rb
with the following error:
Unknown type 'numeric[]' for column 'rate'
(b) However, ActiveRecord still works and is fetching data from the underlying table. Unfortunately it is returning the data as an array of strings instead of an array of BigDecimals.
We've been developing locally with success. Just deployed to Heroku and got this error...
ActiveRecord::StatementInvalid (PG::Error: ERROR: array value must start with "{" or dimension information
LINE 1: UPDATE "users" SET "fb_connections" = '''{"120139","503009",...
Migration looks like this:
t.string_array :fb_connections, default: []
Code:
user.roles = (user.roles || []) + [role_name]
user.save
Get:
PG::Error: ERROR: array value must start with "{" or dimension information
LINE 1: ..._name" = 'Admin', "last_name" = 'Shop', "roles" = '''{"admin...
^
: UPDATE "users" SET "encrypted_password" = '$2a$10$cWhCkffLHVGnv9S47nJZr.ycMe.3Gc./rcEqCq7paG1JZ.fhV3y8y', "first_name" = 'Admin', "middle_name" = 'Admin', "last_name" = 'Shop', "roles" = '''{"admin",customer}''', "confirmed_at" = '2013-02-06 08:07:13.428599', "created_at" = '2013-02-06 08:07:13.461182', "updated_at" = '2013-02-06 08:07:13.461182', "unconfirmed_email" = '[email protected]' WHERE "users"."id" = 1
Working variant:
user.roles = [] + (user.roles || []) + [role_name]
undefined method type_to_sql' for nil:NilClass/home/eug/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-postgres-array-0.0.10/lib/activerecord-postgres-array/activerecord.rb:80:in
block (2 levels) in class:TableDefinition'
Hey @tlconnor,
I'm working in a legacy project which we're trying to upgrade but right now that's not possible (lot of code, can't stop the production servers, almost no coverage, etc) so we have to keep with rails 3.0.20 for now.
The problem is happening with all models which have serialized attributes, all of this models there is no array columns btw.
You can reproduce the problem creating a empty model with a serialized attribute like this:
class Post < ActiveRecord::Base
serialize :meta
end
When we try to create a record, the following exception is raised:
NoMethodError (undefined method `serialized_value' for #<ActiveSupport::HashWithIndifferentAccess:0x007f86ecc36610>)
Looking at source code, I found the problem at this line.
The problem is that method is different for each version of active record:
I fixed it monkey patching the method to the similar version for 3.0 on my application but it would be great if we fix that on activerecord-postgres-array since we will keep using it until we can get to 4.0 which is planned to 5 or 6 months from now.
In the past we did a kind of check for each version of active record on ar-octopus due to a similar problem, you can see the solution at these lines which is not elegant but solves the same problem.
What do you think? Would you accept a pull request fixing the compatibility for rails 3.0 and 3.1?
Fails on type cast. Whin trying to save model Orders it fails:
Order.create :list => [1,2,3,4]
Constructed sql:
INSERT INTO "orders" ("list", "created_at", "updated_at") VALUES (---
- 18
- 18
- 21
- 44
, '2011-09-29 14:11:31.480726', '2011-09-29 14:11:31.480726') RETURNING "id"
Migration is as follows
t.decimal_array :list
Error was
PGError: ERROR: column "list" is of type numeric[] but expression is of type integer
LINE 2: - 18
For an empty array, the default ends up looking like :default => '{}'
in schema.rb, however, this doesn't get single-quoted when turned into a CREATE TABLE
statement, causing rake db:schema:load
to fail.
The following patch fixes it for string arrays, by causing it to be encoded in schema.rb as :default => []
and could probably be generalized:
require 'active_record/connection_adapters/postgresql_adapter'
module ConnectionAdapters
class PostgreSQLColumn < Column
class << self
def extract_value_from_default_with_array(default)
case default
when NilClass
nil
# Arrays
when /\A'(.*)'::"?character varying.*"?\[\]\z/
$1.from_postgres_array(:string)
else
extract_value_from_default_without_array(default)
end
end
alias_method_chain :extract_value_from_default, :array
end
end
end
Upgrading to v0.0.10 breaks my current application.
PG::InvalidTextRepresentation: ERROR: array value must start with "{" or dimension information
I receive this error if the array is empty, haven't tested with an array with values.
Version v0.0.9, which doesn't throw error
["modifier_ids", "{}"]
Version v0.0.10, which throws error
["modifier_ids", "'{}'"]
I'm on Postgres 9.1.3.
>> Request
=> Request(id: integer, inserts: integer_array, updates: integer_array)
>> r = Request.new
=> #<Request id: nil, inserts: [], updates: []>
>> # These array columns have an empty array set as default!
>> r.inserts
=> []
>> # This doesn't work
>> r.inserts << 7
=> [7]
>> r.inserts
=> []
>> # But this does
>> r.inserts += [7]
=> [7]
>> r.inserts
=> [7]
>> # And now, this too
>> r.inserts << 9
=> [7, 9]
>> r.inserts
=> [7, 9]
I've been using this gem for over a year, and I just ran bundle update and for some reason now it keeps raising
unit_amenities must be an Array or have a valid array value (''{"balcony","dishwasher","hardwood floors","home office","tile floors"}'')
params[:unit_amenities]
are submitted as follows:
"unit_amenities"=>["balcony",
"dishwasher",
"hardwood floors",
"home office",
"tile floors"],
In the Rails console, this is what I get:
1.9.3p429 :007 > a.unit_amenities
=> ["dishwasher", "balcony"]
1.9.3p429 :008 > a.unit_amenities << "hardwood floors"
=> ["dishwasher", "balcony", "hardwood floors"]
1.9.3p429 :009 > a.save
(0.2ms) BEGIN
(0.9ms) UPDATE "listings" SET "description" = 'Little Italy was once a lively home for the most of the Italian population in New York. state-of-the-art laundry facilities, [...]', "updated_at" = '2013-10-15 18:19:50.153309' WHERE "listings"."id" = 1032369
(23.7ms) COMMIT
=> true
1.9.3p429 :010 > a.unit_amenities
=> ["dishwasher", "balcony"] # is appears that the updates are just completely dropped from the update, also.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.