dynamoid / dynamoid Goto Github PK
View Code? Open in Web Editor NEWRuby ORM for Amazon's DynamoDB.
License: MIT License
Ruby ORM for Amazon's DynamoDB.
License: MIT License
For
class MyObject
include Dynamoid::Document
field :name
end
this:
MyObject.where("created_at.gt" => DateTime.now - 1.day).all
yields
ArgumentError: unsupported type, expected Hash, Array, Set, String, Numeric, IO, true, false, or nil, got DateTime
Am I missing something?
As I see it, the main advantage of DynamoDB (and Mongo and other document databases) is to be able to nest models in documents. E.g., to have a Person table with string fields like "name" but also fields like "address" which may itself be an object with "street" and "city" and "zip" etc.
Why does Dynamoid spread them into separate tables with foreign keys, effectively relationalizing a document database?
Best,
E
Hi,
I am getting the below error while querying the dynamodb database.
expected hash value for member 1 of key attribute_value_list of value at key is_submitted of option scan_filter
I have recently migrated from dynamoid 0.6 to 1.1.
I am getting this error on line.
Node.where(:is_submitted => 't').where(:is_signed_off => 'f').count
Node is the model in rails application.
Below is the stack trace :
aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:337:in
validate' aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:245:in
block in validate'
aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:243:ineach' aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:243:in
validate'
aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:346:inblock in validate' aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:342:in
each'
aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:342:invalidate' aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:410:in
block in validate'
aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:408:ineach' aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:408:in
validate'
aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:590:inblock in validate' aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:586:in
each'
aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:586:invalidate' aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:611:in
to_h'
aws-sdk (1.20.0) lib/aws/core/option_grammar.rb:621:into_json' aws-sdk (1.20.0) lib/aws/core/json_request_builder.rb:29:in
populate_request'
aws-sdk (1.20.0) lib/aws/core/client.rb:704:inblock (2 levels) in define_client_method' aws-sdk (1.20.0) lib/aws/core/client.rb:549:in
build_request'
aws-sdk (1.20.0) lib/aws/core/client.rb:482:inblock (3 levels) in client_request' aws-sdk (1.20.0) lib/aws/core/response.rb:171:in
call'
aws-sdk (1.20.0) lib/aws/core/response.rb:171:inbuild_request' aws-sdk (1.20.0) lib/aws/core/response.rb:111:in
initialize'
aws-sdk (1.20.0) lib/aws/core/client.rb:195:innew' aws-sdk (1.20.0) lib/aws/core/client.rb:195:in
new_response'
aws-sdk (1.20.0) lib/aws/core/client.rb:481:inblock (2 levels) in client_request' aws-sdk (1.20.0) lib/aws/core/client.rb:382:in
log_client_request'
aws-sdk (1.20.0) lib/aws/core/client.rb:468:inblock in client_request' aws-sdk (1.20.0) lib/aws/core/client.rb:364:in
return_or_raise'
aws-sdk (1.20.0) lib/aws/core/client.rb:467:inclient_request' (eval):3:in
scan'
dynamoid (1.1.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:368:inblock (2 levels) in scan' dynamoid (1.1.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:367:in
loop'
dynamoid (1.1.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:367:inblock in scan' dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:142:in
each'
dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:142:ineach' dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:142:in
block in records_via_scan'
dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:115:ineach' dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:115:in
each'
dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:115:into_a' dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:115:in
Array'
dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:115:inrecords' dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:95:in
each'
app/controllers/application_controller.rb:106:incount' app/controllers/application_controller.rb:106:in
set_global_counts'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:429:inblock in make_lambda' activesupport (4.1.14.2) lib/active_support/callbacks.rb:143:in
call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:143:inblock in halting_and_conditional' activesupport (4.1.14.2) lib/active_support/callbacks.rb:501:in
call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:501:inblock in call' activesupport (4.1.14.2) lib/active_support/callbacks.rb:501:in
each'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:501:incall' activesupport (4.1.14.2) lib/active_support/callbacks.rb:86:in
run_callbacks'
actionpack (4.1.14.2) lib/abstract_controller/callbacks.rb:19:inprocess_action' actionpack (4.1.14.2) lib/action_controller/metal/rescue.rb:29:in
process_action'
actionpack (4.1.14.2) lib/action_controller/metal/instrumentation.rb:32:inblock in process_action' activesupport (4.1.14.2) lib/active_support/notifications.rb:159:in
block in instrument'
activesupport (4.1.14.2) lib/active_support/notifications/instrumenter.rb:20:ininstrument' activesupport (4.1.14.2) lib/active_support/notifications.rb:159:in
instrument'
actionpack (4.1.14.2) lib/action_controller/metal/instrumentation.rb:30:inprocess_action' actionpack (4.1.14.2) lib/action_controller/metal/params_wrapper.rb:250:in
process_action'
actionpack (4.1.14.2) lib/abstract_controller/base.rb:136:inprocess' actionview (4.1.14.2) lib/action_view/rendering.rb:30:in
process'
actionpack (4.1.14.2) lib/action_controller/metal.rb:196:indispatch' actionpack (4.1.14.2) lib/action_controller/metal/rack_delegation.rb:13:in
dispatch'
actionpack (4.1.14.2) lib/action_controller/metal.rb:232:inblock in action' actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:80:in
call'
actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:80:indispatch' actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:48:in
call'
actionpack (4.1.14.2) lib/action_dispatch/journey/router.rb:73:inblock in call' actionpack (4.1.14.2) lib/action_dispatch/journey/router.rb:59:in
each'
actionpack (4.1.14.2) lib/action_dispatch/journey/router.rb:59:incall' actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:690:in
call'
rack (1.5.2) lib/rack/etag.rb:23:incall' rack (1.5.2) lib/rack/conditionalget.rb:25:in
call'
rack (1.5.2) lib/rack/head.rb:11:incall' actionpack (4.1.14.2) lib/action_dispatch/middleware/params_parser.rb:27:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/flash.rb:254:incall' rack (1.5.2) lib/rack/session/abstract/id.rb:225:in
context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:incall' actionpack (4.1.14.2) lib/action_dispatch/middleware/cookies.rb:562:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call' activesupport (4.1.14.2) lib/active_support/callbacks.rb:82:in
run_callbacks'
actionpack (4.1.14.2) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (4.1.14.2) lib/action_dispatch/middleware/reloader.rb:73:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/remote_ip.rb:76:incall' actionpack (4.1.14.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/show_exceptions.rb:30:incall' railties (4.1.14.2) lib/rails/rack/logger.rb:38:in
call_app'
railties (4.1.14.2) lib/rails/rack/logger.rb:20:inblock in call' activesupport (4.1.14.2) lib/active_support/tagged_logging.rb:68:in
block in tagged'
activesupport (4.1.14.2) lib/active_support/tagged_logging.rb:26:intagged' activesupport (4.1.14.2) lib/active_support/tagged_logging.rb:68:in
tagged'
railties (4.1.14.2) lib/rails/rack/logger.rb:20:incall' /opt/brazil-pkg-cache/packages/AmazonRailsLogger/AmazonRailsLogger-4.0.80.53/RHEL5_64/DEV.STD.PTHREAD/build/ruby1.9/site_ruby/1.9.1/amazon/set_request_id.rb:9:in
call'
/opt/brazil-pkg-cache/packages/AmazonRailsLogger/AmazonRailsLogger-4.0.80.53/RHEL5_64/DEV.STD.PTHREAD/build/ruby1.9/site_ruby/1.9.1/amazon/set_request_id.rb:9:incall' actionpack (4.1.14.2) lib/action_dispatch/middleware/request_id.rb:21:in
call'
rack (1.5.2) lib/rack/methodoverride.rb:21:incall' rack (1.5.2) lib/rack/runtime.rb:17:in
call'
activesupport (4.1.14.2) lib/active_support/cache/strategy/local_cache_middleware.rb:26:incall' rack (1.5.2) lib/rack/lock.rb:17:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/static.rb:84:incall' rack (1.5.2) lib/rack/sendfile.rb:112:in
call'
railties (4.1.14.2) lib/rails/engine.rb:514:incall' railties (4.1.14.2) lib/rails/application.rb:144:in
call'
railties (4.1.14.2) lib/rails/railtie.rb:194:inpublic_send' railties (4.1.14.2) lib/rails/railtie.rb:194:in
method_missing'
rack (1.5.2) lib/rack/lint.rb:49:in_call' rack (1.5.2) lib/rack/lint.rb:37:in
call'
rack (1.5.2) lib/rack/showexceptions.rb:24:incall' rack (1.5.2) lib/rack/commonlogger.rb:33:in
call'
rack (1.5.2) lib/rack/chunked.rb:43:incall' rack (1.5.2) lib/rack/content_length.rb:14:in
call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:inservice' /home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/webrick/httpserver.rb:138:in
service'
/home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/webrick/httpserver.rb:94:inrun' /home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/webrick/server.rb:191:in
block in start_thread'
Can anyone help me in this?
class User
include Dynamoid::Document
field :name, :string, {:default => "test"}
end
u = User.new(:name => nil)
# name value is set to "test" instead of nil here
u.name # => "test"
u = User.new
# default here is fine
u.name # => "test"
Default should only be set if the attribute was not set on initialize
I've been rewriting a legacy app in Ruby. When I try to provide a custom name to my table name Dynamoid prepends namespace to the table name. It would be great if we can skip namespace in configuration. I also tried leaving the namespace blank which results in _
before the table name.
When we define hash_key and range_key with some types, we have to write as bellow:
class Comment
include Dynamoid::Document
table :name => :comment , :key => :user_id, :range_key => :comment_id
range :comment_id, :integer
field :user_id, :integer
end
This notation is a little redundant. I would rather write as:
class Comment
include Dynamoid::Document
table :name => :comment
hash_key :user_id, :integer
range_key :comment_id, :integer
end
Import event dates from the organisators websites
Dynamoid automatically adds the fields created_at and updated_at. But I'm reading from a table that doesn't follow Rails conventions and doesn't have those fields. How do I remove them from the table definition?
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SecondaryIndexes.html
Right now it seems like the adapter only supports querying against the table with primary hash and range keys. The index support needs to be added back w/ support for secondary indexes (the index name, hash key, optional range key).
For now I was able to shoehorn the support in by extending the AwsSdkV2 adapter with a new method:
config.adapter = 'aws_sdk_v2_secondary_index'
module Dynamoid
module AdapterPlugin
# Extend Dynamoid Adapter to add support for querying Secondary Indexes
class AwsSdkV2SecondaryIndex < AwsSdkV2
def query_secondary_index(table_name, index_name, key_conditions, options = {})
q = {
table_name: table_name,
index_name: index_name,
key_conditions: key_conditions
}
Enumerator.new { |y|
result = client.query(q)
result.items.each { |r|
y << result_item_to_hash(r)
}
}
end
end
end
end
# There may be a better way to write this using Dynamoid's 'field.gt' but I couldn't figure it out
def self.find_all_by_customer_id_and_created_at_greater_than(customer_id, created_at_greater_than)
key_conditions = {
'customer_id' => {
comparison_operator: 'EQ',
attribute_value_list: [customer_id.to_i]
},
'created_at' => {
comparison_operator: 'GT',
attribute_value_list: [created_at_greater_than.to_i]
}
}
Dynamoid.adapter.query_secondary_index(self.table_name, 'customer_id-created_at-index', key_conditions).collect do |item|
from_database(item)
end
end
Other thoughts: maybe the first step towards enhanced DynamoDB API support is a new convenience adapter method to use client.query + result_item_to_hash. The method could be used from Dynamoid::Document classes.
Dynamoid raises Dynamoid::Errors::ConditionalCheckFailedException for two cases:
We want to distinguish between these two cases, following ActiveRecord:
case 1 -> RecordNotUnique
case 2 -> StaleObjectError
We discovered this quite unpleasantly via accidentally hitting Dynamoid::Finders#method_missing when a refactor failed to configure some custom find_by methods under certain circumstances not caught by our test suite, but it seems like we can probably refactor this to use indexes when the find by is on an indexed attribute, if we define Dynamoid::Criteria::Chain#first to reflect on indexes and do find_all_by_secondary_index(chain.query).first
or something to that effect. Possibly we can also add a config option to error instead of falling back on Enumerable#first if the indexes don't exist, as that may be preferable to doing a full table scan.
AWS SDK v2 supports an optional scan_filter
on Scan API calls, with the same semantics as query_filter
on Query API calls.
Dynamoid offers convenience methods for finding on range fields, such as my_chain.where("rangefield.gt" => 5)
, but it works only on Query API calls. On Scan, Dynamoid allows this query chain, but it does not translate the ".gt" component, so you end up scanning for a non-existent field.
We need the range finding functionality to be consistent between Query and Scan.
HI,
I am having a rails application with dynamodb as database.
Ruby : 1.9.1
Ruby On Rails : 4.1
DynamoDB : 1.1
I am getting this error :
/home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/set.rb:85:in
do_with_enum' /home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/set.rb:310:in
merge'
/home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/set.rb:75:ininitialize' dynamoid (1.1.0) lib/dynamoid/persistence.rb:99:in
new'
dynamoid (1.1.0) lib/dynamoid/persistence.rb:99:inundump_field' dynamoid (1.1.0) lib/dynamoid/persistence.rb:61:in
block (2 levels) in undump'
dynamoid (1.1.0) lib/dynamoid/persistence.rb:60:ineach' dynamoid (1.1.0) lib/dynamoid/persistence.rb:60:in
block in undump'
dynamoid (1.1.0) lib/dynamoid/persistence.rb:59:intap' dynamoid (1.1.0) lib/dynamoid/persistence.rb:59:in
undump'
dynamoid (1.1.0) lib/dynamoid/document.rb:133:inload' dynamoid (1.1.0) lib/dynamoid/document.rb:128:in
block in initialize'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:113:incall' activesupport (4.1.14.2) lib/active_support/callbacks.rb:113:in
call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:552:inblock (2 levels) in compile' activesupport (4.1.14.2) lib/active_support/callbacks.rb:502:in
call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:502:incall' activesupport (4.1.14.2) lib/active_support/callbacks.rb:86:in
run_callbacks'
dynamoid (1.1.0) lib/dynamoid/document.rb:123:ininitialize' dynamoid (1.1.0) lib/dynamoid/persistence.rb:51:in
new'
dynamoid (1.1.0) lib/dynamoid/persistence.rb:51:infrom_database' dynamoid (1.1.0) lib/dynamoid/identity_map.rb:15:in
from_database'
dynamoid (1.1.0) lib/dynamoid/dirty.rb:8:infrom_database' dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:143:in
block (2 levels) in records_via_scan'
dynamoid (1.1.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:370:in<<' dynamoid (1.1.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:370:in
block (3 levels) in scan'
dynamoid (1.1.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:370:ineach' dynamoid (1.1.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:370:in
block (2 levels) in scan'
dynamoid (1.1.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:367:inloop' dynamoid (1.1.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:367:in
block in scan'
dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:142:ineach' dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:142:in
each'
dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:142:inblock in records_via_scan' dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:115:in
each'
dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:115:ineach' dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:115:in
to_a'
dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:115:inArray' dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:115:in
records'
dynamoid (1.1.0) lib/dynamoid/criteria/chain.rb:46:inall' app/models/node.rb:931:in
all_non_confidential_worldwide'
lib/brazil_config_helper.rb:162:inget_node_names' app/views/tabs/_site_information_fields.html.slim:49:in
_app_views_tabs__site_information_fields_html_slim__1161341738563972731_69854304393120'
actionview (4.1.14.2) lib/action_view/template.rb:145:inblock in render' activesupport (4.1.14.2) lib/active_support/notifications.rb:161:in
instrument'
actionview (4.1.14.2) lib/action_view/template.rb:339:ininstrument' actionview (4.1.14.2) lib/action_view/template.rb:143:in
render'
actionview (4.1.14.2) lib/action_view/renderer/partial_renderer.rb:306:inrender_partial' actionview (4.1.14.2) lib/action_view/renderer/partial_renderer.rb:279:in
block in render'
actionview (4.1.14.2) lib/action_view/renderer/abstract_renderer.rb:38:inblock in instrument' activesupport (4.1.14.2) lib/active_support/notifications.rb:159:in
block in instrument'
activesupport (4.1.14.2) lib/active_support/notifications/instrumenter.rb:20:ininstrument' activesupport (4.1.14.2) lib/active_support/notifications.rb:159:in
instrument'
actionview (4.1.14.2) lib/action_view/renderer/abstract_renderer.rb:38:ininstrument' actionview (4.1.14.2) lib/action_view/renderer/partial_renderer.rb:278:in
render'
actionview (4.1.14.2) lib/action_view/renderer/renderer.rb:51:inrender_partial' actionview (4.1.14.2) lib/action_view/helpers/rendering_helper.rb:35:in
render'
haml (4.0.0) lib/haml/helpers/action_view_mods.rb:12:inrender_with_haml' app/views/tabs/_read_only_form.html.slim:11:in
block in _app_views_tabs__read_only_form_html_slim___379420859086536323_69853819859700'
app/views/tabs/_read_only_form.html.slim:8:ineach' app/views/tabs/_read_only_form.html.slim:8:in
_app_views_tabs__read_only_form_html_slim___379420859086536323_69853819859700'
actionview (4.1.14.2) lib/action_view/template.rb:145:inblock in render' activesupport (4.1.14.2) lib/active_support/notifications.rb:161:in
instrument'
actionview (4.1.14.2) lib/action_view/template.rb:339:ininstrument' actionview (4.1.14.2) lib/action_view/template.rb:143:in
render'
actionview (4.1.14.2) lib/action_view/renderer/partial_renderer.rb:306:inrender_partial' actionview (4.1.14.2) lib/action_view/renderer/partial_renderer.rb:279:in
block in render'
actionview (4.1.14.2) lib/action_view/renderer/abstract_renderer.rb:38:inblock in instrument' activesupport (4.1.14.2) lib/active_support/notifications.rb:159:in
block in instrument'
activesupport (4.1.14.2) lib/active_support/notifications/instrumenter.rb:20:ininstrument' activesupport (4.1.14.2) lib/active_support/notifications.rb:159:in
instrument'
actionview (4.1.14.2) lib/action_view/renderer/abstract_renderer.rb:38:ininstrument' actionview (4.1.14.2) lib/action_view/renderer/partial_renderer.rb:278:in
render'
actionview (4.1.14.2) lib/action_view/renderer/renderer.rb:51:inrender_partial' actionview (4.1.14.2) lib/action_view/helpers/rendering_helper.rb:35:in
render'
haml (4.0.0) lib/haml/helpers/action_view_mods.rb:12:inrender_with_haml' app/views/tabs/show.html.slim:7:in
block in _app_views_tabs_show_html_slim___2573104391332512245_69853756219540'
actionview (4.1.14.2) lib/action_view/helpers/capture_helper.rb:38:inblock in capture' actionview (4.1.14.2) lib/action_view/helpers/capture_helper.rb:202:in
with_output_buffer'
haml (4.0.0) lib/haml/helpers/action_view_xss_mods.rb:5:inwith_output_buffer_with_haml_xss' actionview (4.1.14.2) lib/action_view/helpers/capture_helper.rb:38:in
capture'
haml (4.0.0) lib/haml/helpers/action_view_mods.rb:59:incapture_with_haml' actionview (4.1.14.2) lib/action_view/helpers/form_helper.rb:434:in
form_for'
haml (4.0.0) lib/haml/helpers/action_view_mods.rb:135:inform_for_with_haml' haml (4.0.0) lib/haml/helpers/action_view_xss_mods.rb:28:in
form_for_with_haml_xss'
app/views/tabs/show.html.slim:6:in_app_views_tabs_show_html_slim___2573104391332512245_69853756219540' actionview (4.1.14.2) lib/action_view/template.rb:145:in
block in render'
activesupport (4.1.14.2) lib/active_support/notifications.rb:161:ininstrument' actionview (4.1.14.2) lib/action_view/template.rb:339:in
instrument'
actionview (4.1.14.2) lib/action_view/template.rb:143:inrender' actionview (4.1.14.2) lib/action_view/renderer/template_renderer.rb:55:in
block (2 levels) in render_template'
actionview (4.1.14.2) lib/action_view/renderer/abstract_renderer.rb:38:inblock in instrument' activesupport (4.1.14.2) lib/active_support/notifications.rb:159:in
block in instrument'
activesupport (4.1.14.2) lib/active_support/notifications/instrumenter.rb:20:ininstrument' activesupport (4.1.14.2) lib/active_support/notifications.rb:159:in
instrument'
actionview (4.1.14.2) lib/action_view/renderer/abstract_renderer.rb:38:ininstrument' actionview (4.1.14.2) lib/action_view/renderer/template_renderer.rb:54:in
block in render_template'
actionview (4.1.14.2) lib/action_view/renderer/template_renderer.rb:62:inrender_with_layout' actionview (4.1.14.2) lib/action_view/renderer/template_renderer.rb:53:in
render_template'
actionview (4.1.14.2) lib/action_view/renderer/template_renderer.rb:17:inrender' actionview (4.1.14.2) lib/action_view/renderer/renderer.rb:46:in
render_template'
actionview (4.1.14.2) lib/action_view/renderer/renderer.rb:27:inrender' actionview (4.1.14.2) lib/action_view/rendering.rb:99:in
_render_template'
actionpack (4.1.14.2) lib/action_controller/metal/streaming.rb:217:in_render_template' actionview (4.1.14.2) lib/action_view/rendering.rb:82:in
render_to_body'
actionpack (4.1.14.2) lib/action_controller/metal/rendering.rb:32:inrender_to_body' actionpack (4.1.14.2) lib/action_controller/metal/renderers.rb:32:in
render_to_body'
actionpack (4.1.14.2) lib/abstract_controller/rendering.rb:25:inrender' actionpack (4.1.14.2) lib/action_controller/metal/rendering.rb:16:in
render'
actionpack (4.1.14.2) lib/action_controller/metal/instrumentation.rb:44:inblock (2 levels) in render' activesupport (4.1.14.2) lib/active_support/core_ext/benchmark.rb:12:in
block in ms'
/home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/benchmark.rb:295:inrealtime' activesupport (4.1.14.2) lib/active_support/core_ext/benchmark.rb:12:in
ms'
actionpack (4.1.14.2) lib/action_controller/metal/instrumentation.rb:44:inblock in render' actionpack (4.1.14.2) lib/action_controller/metal/instrumentation.rb:87:in
cleanup_view_runtime'
actionpack (4.1.14.2) lib/action_controller/metal/instrumentation.rb:43:inrender' app/controllers/nodes_controller.rb:43:in
block (2 levels) in show'
actionpack (4.1.14.2) lib/action_controller/metal/mime_responds.rb:258:incall' actionpack (4.1.14.2) lib/action_controller/metal/mime_responds.rb:258:in
respond_to'
app/controllers/nodes_controller.rb:42:inshow' actionpack (4.1.14.2) lib/action_controller/metal/implicit_render.rb:4:in
send_action'
actionpack (4.1.14.2) lib/abstract_controller/base.rb:189:inprocess_action' actionpack (4.1.14.2) lib/action_controller/metal/rendering.rb:10:in
process_action'
actionpack (4.1.14.2) lib/abstract_controller/callbacks.rb:20:inblock in process_action' activesupport (4.1.14.2) lib/active_support/callbacks.rb:113:in
call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:113:incall' activesupport (4.1.14.2) lib/active_support/callbacks.rb:552:in
block (2 levels) in compile'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:502:incall' activesupport (4.1.14.2) lib/active_support/callbacks.rb:502:in
call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:86:inrun_callbacks' actionpack (4.1.14.2) lib/abstract_controller/callbacks.rb:19:in
process_action'
actionpack (4.1.14.2) lib/action_controller/metal/rescue.rb:29:inprocess_action' actionpack (4.1.14.2) lib/action_controller/metal/instrumentation.rb:32:in
block in process_action'
activesupport (4.1.14.2) lib/active_support/notifications.rb:159:inblock in instrument' activesupport (4.1.14.2) lib/active_support/notifications/instrumenter.rb:20:in
instrument'
activesupport (4.1.14.2) lib/active_support/notifications.rb:159:ininstrument' actionpack (4.1.14.2) lib/action_controller/metal/instrumentation.rb:30:in
process_action'
actionpack (4.1.14.2) lib/action_controller/metal/params_wrapper.rb:250:inprocess_action' actionpack (4.1.14.2) lib/abstract_controller/base.rb:136:in
process'
actionview (4.1.14.2) lib/action_view/rendering.rb:30:inprocess' actionpack (4.1.14.2) lib/action_controller/metal.rb:196:in
dispatch'
actionpack (4.1.14.2) lib/action_controller/metal/rack_delegation.rb:13:indispatch' actionpack (4.1.14.2) lib/action_controller/metal.rb:232:in
block in action'
actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:80:incall' actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:80:in
dispatch'
actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:48:incall' actionpack (4.1.14.2) lib/action_dispatch/journey/router.rb:73:in
block in call'
actionpack (4.1.14.2) lib/action_dispatch/journey/router.rb:59:ineach' actionpack (4.1.14.2) lib/action_dispatch/journey/router.rb:59:in
call'
actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:690:incall' rack (1.5.2) lib/rack/etag.rb:23:in
call'
rack (1.5.2) lib/rack/conditionalget.rb:25:incall' rack (1.5.2) lib/rack/head.rb:11:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/params_parser.rb:27:incall' actionpack (4.1.14.2) lib/action_dispatch/middleware/flash.rb:254:in
call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:incontext' rack (1.5.2) lib/rack/session/abstract/id.rb:220:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/cookies.rb:562:incall' actionpack (4.1.14.2) lib/action_dispatch/middleware/callbacks.rb:29:in
block in call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:82:inrun_callbacks' actionpack (4.1.14.2) lib/action_dispatch/middleware/callbacks.rb:27:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/reloader.rb:73:incall' actionpack (4.1.14.2) lib/action_dispatch/middleware/remote_ip.rb:76:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall' actionpack (4.1.14.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in
call'
railties (4.1.14.2) lib/rails/rack/logger.rb:38:incall_app' railties (4.1.14.2) lib/rails/rack/logger.rb:20:in
block in call'
activesupport (4.1.14.2) lib/active_support/tagged_logging.rb:68:inblock in tagged' activesupport (4.1.14.2) lib/active_support/tagged_logging.rb:26:in
tagged'
activesupport (4.1.14.2) lib/active_support/tagged_logging.rb:68:intagged' railties (4.1.14.2) lib/rails/rack/logger.rb:20:in
call'
/opt/brazil-pkg-cache/packages/AmazonRailsLogger/AmazonRailsLogger-4.0.80.62/RHEL5_64/DEV.STD.PTHREAD/build/ruby1.9/site_ruby/1.9.1/amazon/set_request_id.rb:9:incall' /opt/brazil-pkg-cache/packages/AmazonRailsLogger/AmazonRailsLogger-4.0.80.62/RHEL5_64/DEV.STD.PTHREAD/build/ruby1.9/site_ruby/1.9.1/amazon/set_request_id.rb:9:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/request_id.rb:21:incall' rack (1.5.2) lib/rack/methodoverride.rb:21:in
call'
rack (1.5.2) lib/rack/runtime.rb:17:incall' activesupport (4.1.14.2) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in
call'
rack (1.5.2) lib/rack/lock.rb:17:incall' actionpack (4.1.14.2) lib/action_dispatch/middleware/static.rb:84:in
call'
rack (1.5.2) lib/rack/sendfile.rb:112:incall' railties (4.1.14.2) lib/rails/engine.rb:514:in
call'
railties (4.1.14.2) lib/rails/application.rb:144:incall' railties (4.1.14.2) lib/rails/railtie.rb:194:in
public_send'
railties (4.1.14.2) lib/rails/railtie.rb:194:inmethod_missing' rack (1.5.2) lib/rack/lint.rb:49:in
_call'
rack (1.5.2) lib/rack/lint.rb:37:incall' rack (1.5.2) lib/rack/showexceptions.rb:24:in
call'
rack (1.5.2) lib/rack/commonlogger.rb:33:incall' rack (1.5.2) lib/rack/chunked.rb:43:in
call'
rack (1.5.2) lib/rack/content_length.rb:14:incall' rack (1.5.2) lib/rack/handler/webrick.rb:60:in
service'
/home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/webrick/httpserver.rb:138:inservice' /home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/webrick/httpserver.rb:94:in
run'
/home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/webrick/server.rb:191:in `block in start_thread'
The error is in this line :
Node.where(:is_confidential => 'f').all
Can anyone help me in this?
Hi,
I am using Dynamoid version 1.0 and I am getting the following error while executing the line :
Line :
Node.where(:region => region).where(:is_completed => 'f').count
Error:
value must be enumerable
Logs:
/home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/set.rb:85:in do_with_enum' /home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/set.rb:310:in
merge'
/home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/set.rb:75:in initialize' dynamoid (1.0.0) lib/dynamoid/persistence.rb:99:in
new'
dynamoid (1.0.0) lib/dynamoid/persistence.rb:99:in undump_field' dynamoid (1.0.0) lib/dynamoid/persistence.rb:61:in
block (2 levels) in undump'
dynamoid (1.0.0) lib/dynamoid/persistence.rb:60:in each' dynamoid (1.0.0) lib/dynamoid/persistence.rb:60:in
block in undump'
dynamoid (1.0.0) lib/dynamoid/persistence.rb:59:in tap' dynamoid (1.0.0) lib/dynamoid/persistence.rb:59:in
undump'
dynamoid (1.0.0) lib/dynamoid/document.rb:133:in load' dynamoid (1.0.0) lib/dynamoid/document.rb:128:in
block in initialize'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:113:in call' activesupport (4.1.14.2) lib/active_support/callbacks.rb:113:in
call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:552:in block (2 levels) in compile' activesupport (4.1.14.2) lib/active_support/callbacks.rb:502:in
call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:502:in call' activesupport (4.1.14.2) lib/active_support/callbacks.rb:86:in
run_callbacks'
dynamoid (1.0.0) lib/dynamoid/document.rb:123:in initialize' dynamoid (1.0.0) lib/dynamoid/persistence.rb:51:in
new'
dynamoid (1.0.0) lib/dynamoid/persistence.rb:51:in from_database' dynamoid (1.0.0) lib/dynamoid/identity_map.rb:15:in
from_database'
dynamoid (1.0.0) lib/dynamoid/dirty.rb:8:in from_database' dynamoid (1.0.0) lib/dynamoid/criteria/chain.rb:143:in
block (2 levels) in records_via_scan'
dynamoid (1.0.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:362:in <<' dynamoid (1.0.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:362:in
block (3 levels) in scan'
dynamoid (1.0.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:362:in each' dynamoid (1.0.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:362:in
block (2 levels) in scan'
dynamoid (1.0.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:359:in loop' dynamoid (1.0.0) lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:359:in
block in scan'
dynamoid (1.0.0) lib/dynamoid/criteria/chain.rb:142:in each' dynamoid (1.0.0) lib/dynamoid/criteria/chain.rb:142:in
each'
dynamoid (1.0.0) lib/dynamoid/criteria/chain.rb:142:in block in records_via_scan' dynamoid (1.0.0) lib/dynamoid/criteria/chain.rb:115:in
each'
dynamoid (1.0.0) lib/dynamoid/criteria/chain.rb:115:in each' dynamoid (1.0.0) lib/dynamoid/criteria/chain.rb:115:in
to_a'
dynamoid (1.0.0) lib/dynamoid/criteria/chain.rb:115:in Array' dynamoid (1.0.0) lib/dynamoid/criteria/chain.rb:115:in
records'
dynamoid (1.0.0) lib/dynamoid/criteria/chain.rb:95:in each' app/models/node.rb:925:in
count'
app/models/node.rb:925:in all_in_region_and_incomplete' app/controllers/nodes_controller.rb:201:in
all_in_region_and_incomplete'
app/controllers/nodes_controller.rb:13:in index' actionpack (4.1.14.2) lib/action_controller/metal/implicit_render.rb:4:in
send_action'
actionpack (4.1.14.2) lib/abstract_controller/base.rb:189:in process_action' actionpack (4.1.14.2) lib/action_controller/metal/rendering.rb:10:in
process_action'
actionpack (4.1.14.2) lib/abstract_controller/callbacks.rb:20:in block in process_action' activesupport (4.1.14.2) lib/active_support/callbacks.rb:113:in
call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:113:in call' activesupport (4.1.14.2) lib/active_support/callbacks.rb:552:in
block (2 levels) in compile'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:502:in call' activesupport (4.1.14.2) lib/active_support/callbacks.rb:502:in
call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:86:in run_callbacks' actionpack (4.1.14.2) lib/abstract_controller/callbacks.rb:19:in
process_action'
actionpack (4.1.14.2) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (4.1.14.2) lib/action_controller/metal/instrumentation.rb:32:in
block in process_action'
activesupport (4.1.14.2) lib/active_support/notifications.rb:159:in block in instrument' activesupport (4.1.14.2) lib/active_support/notifications/instrumenter.rb:20:in
instrument'
activesupport (4.1.14.2) lib/active_support/notifications.rb:159:in instrument' actionpack (4.1.14.2) lib/action_controller/metal/instrumentation.rb:30:in
process_action'
actionpack (4.1.14.2) lib/action_controller/metal/params_wrapper.rb:250:in process_action' actionpack (4.1.14.2) lib/abstract_controller/base.rb:136:in
process'
actionview (4.1.14.2) lib/action_view/rendering.rb:30:in process' actionpack (4.1.14.2) lib/action_controller/metal.rb:196:in
dispatch'
actionpack (4.1.14.2) lib/action_controller/metal/rack_delegation.rb:13:in dispatch' actionpack (4.1.14.2) lib/action_controller/metal.rb:232:in
block in action'
actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:80:in call' actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:80:in
dispatch'
actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:48:in call' actionpack (4.1.14.2) lib/action_dispatch/journey/router.rb:73:in
block in call'
actionpack (4.1.14.2) lib/action_dispatch/journey/router.rb:59:in each' actionpack (4.1.14.2) lib/action_dispatch/journey/router.rb:59:in
call'
actionpack (4.1.14.2) lib/action_dispatch/routing/route_set.rb:690:in call' rack (1.5.2) lib/rack/etag.rb:23:in
call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in call' rack (1.5.2) lib/rack/head.rb:11:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/params_parser.rb:27:in call' actionpack (4.1.14.2) lib/action_dispatch/middleware/flash.rb:254:in
call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in context' rack (1.5.2) lib/rack/session/abstract/id.rb:220:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/cookies.rb:562:in call' actionpack (4.1.14.2) lib/action_dispatch/middleware/callbacks.rb:29:in
block in call'
activesupport (4.1.14.2) lib/active_support/callbacks.rb:82:in run_callbacks' actionpack (4.1.14.2) lib/action_dispatch/middleware/callbacks.rb:27:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/reloader.rb:73:in call' actionpack (4.1.14.2) lib/action_dispatch/middleware/remote_ip.rb:76:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' actionpack (4.1.14.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in
call'
railties (4.1.14.2) lib/rails/rack/logger.rb:38:in call_app' railties (4.1.14.2) lib/rails/rack/logger.rb:20:in
block in call'
activesupport (4.1.14.2) lib/active_support/tagged_logging.rb:68:in block in tagged' activesupport (4.1.14.2) lib/active_support/tagged_logging.rb:26:in
tagged'
activesupport (4.1.14.2) lib/active_support/tagged_logging.rb:68:in tagged' railties (4.1.14.2) lib/rails/rack/logger.rb:20:in
call'
/opt/brazil-pkg-cache/packages/AmazonRailsLogger/AmazonRailsLogger-4.0.80.55/RHEL5_64/DEV.STD.PTHREAD/build/ruby1.9/site_ruby/1.9.1/amazon/set_request_id.rb:9:in call' /opt/brazil-pkg-cache/packages/AmazonRailsLogger/AmazonRailsLogger-4.0.80.55/RHEL5_64/DEV.STD.PTHREAD/build/ruby1.9/site_ruby/1.9.1/amazon/set_request_id.rb:9:in
call'
actionpack (4.1.14.2) lib/action_dispatch/middleware/request_id.rb:21:in call' rack (1.5.2) lib/rack/methodoverride.rb:21:in
call'
rack (1.5.2) lib/rack/runtime.rb:17:in call' activesupport (4.1.14.2) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in
call'
rack (1.5.2) lib/rack/lock.rb:17:in call' actionpack (4.1.14.2) lib/action_dispatch/middleware/static.rb:84:in
call'
rack (1.5.2) lib/rack/sendfile.rb:112:in call' railties (4.1.14.2) lib/rails/engine.rb:514:in
call'
railties (4.1.14.2) lib/rails/application.rb:144:in call' railties (4.1.14.2) lib/rails/railtie.rb:194:in
public_send'
railties (4.1.14.2) lib/rails/railtie.rb:194:in method_missing' rack (1.5.2) lib/rack/lint.rb:49:in
_call'
rack (1.5.2) lib/rack/lint.rb:37:in call' rack (1.5.2) lib/rack/showexceptions.rb:24:in
call'
rack (1.5.2) lib/rack/commonlogger.rb:33:in call' rack (1.5.2) lib/rack/chunked.rb:43:in
call'
rack (1.5.2) lib/rack/content_length.rb:14:in call' rack (1.5.2) lib/rack/handler/webrick.rb:60:in
service'
/home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/webrick/httpserver.rb:138:in service' /home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/webrick/httpserver.rb:94:in
run'
/home/lakhwani/FCLaunchRequirement/env/FCLaunchRequirementWebsite-1.0/runtime/ruby1.9/1.9.1/webrick/server.rb:191:in `block in start_thread'
Can any one please help me in this issue?
Is there any collision?
I am setting my configuration to the following:
config.adapter = 'aws_sdk_v2'
config.namespace = nil
config.warn_on_scan = true
config.read_capacity = 5
config.write_capacity = 5
However, when i get the result I am getting the following:
get_item(table_name:"_tableName",key:{"email"=>{s:"[email protected]"}})
In this example my table is called "tableName" however it is still adding the _, I tried setting config.namespace to "" and nil but it did not work.
Is this an error or did I just misunderstood the documentation?
I am interested in knowing if this was a design decision or is it a bug. I would assume that you shouldn't be able to delete a record if it is out of date.
Hi,
I am using Dynamoid 1.1.0 and I am getting the following error on line:
require 'dynamoid/adapter/aws_sdk'
Error :
cannot load such file -- dynamoid/adapter/aws_sdk
What happened to support for ...
global_secondary_index :hash_key => :name, :range_key => :posted_at
global_secondary_index :hash_key => :length`
I noticed that its included in the test spec spec/app/models/post.rb
, but I don't see it in the Dynamoid::Document
module.
Thanks!
I'm not sure what the chain eval_limit and batch should do e.g.
`SomeModel.eval_limit(5).batch(5)`
Should that get 5 records, in a batch of 5, or 5 batches of 5 records each?
When I tried it it scanned the entire table ignoring the limit.
The documentation states
`Address.limit(10_000).batch(100)`
But limit is not a valid method. It should be eval_limit.
Code to reproduce the problem:
class TestDoc
field :some_array, :array
end
td = TestDoc.new
td.some_array = []
td.save!
td.reload
td.some_array # ==> nil
Hi, I'm a new developer so I'm not sure if this is the best place to ask these questions, let me know if I should move this somewhere else. I'm running a small project in Rails 5 and would like to use Dynamoid, and I saw that support was in the works. Is there any estimate on when that version will be released?
Also, when I assign associations in Dynamoid, is there any built in way to assign ddb documents to ActiveRecord objects? For example, if I am using dynamo to build a new feature for user's posts (comments, photos, videos, etc.) is there a way for me to assign each document in a way where I can call @user.posts and receive an array of Dynamoid objects with foreign keys of user_ids? Is it as simple as defining belongs_to and has_many in the models respectively, even if Users are stored in mysql?
Looks like gem version (ruby gems) 1.1.0 is outdated. It does not support indexes and was built in Dec'2015. Can we update the gem?
If the table does not yet exist, a call to model.save
fails on first call and succeeds on subsequent calls.
irb(main):005:0> r.save
(456.44 ms) LIST TABLES - [[]]
(456.76 ms) CACHE TABLES
Creating olev_residentialapplications table. This could take a while.
(63.21 ms) CREATE TABLE
Aws::DynamoDB::Errors::ResourceNotFoundException: Requested resource not found
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb:112:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/seahorse/client/plugins/response_target.rb:21:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/seahorse/client/request.rb:70:in `send_request'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.3.1/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/adapter_plugin/aws_sdk_v2.rb:249:in `put_item'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/adapter.rb:139:in `block (3 levels) in <class:Adapter>'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/adapter.rb:53:in `benchmark'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/adapter.rb:139:in `block (2 levels) in <class:Adapter>'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/adapter.rb:68:in `write'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/persistence.rb:308:in `block in persist'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:117:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:505:in `call'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
... 8 levels...
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_create_callbacks'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/persistence.rb:165:in `save'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/validations.rb:17:in `save'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/identity_map.rb:68:in `save'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/dirty.rb:13:in `block in save'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/dirty.rb:28:in `clear_changes'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/dynamoid-1.1.0/lib/dynamoid/dirty.rb:13:in `save'
from (irb):5
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/nbt/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'irb(main):006:0> r.save
(595.87 ms) PUT ITEM - [["olev_residentialapplications", {:created_at=>1462523745.554208, :updated_at=>1462523745.554333, :id=>"d703d3fa-dc9b-445d-9b91-fd09a7fec770", :customer_name=>"aaa", :customer_adress=>"111"}, {:unless_exists=>[:id, :id]}]]
From TODO in code:
# @param [Hash] options - @TODO support more options in future such as
# query filter, projected keys etc
Given the configured endpoint is not reachable:
Because of an unconditional rescue in concurrent-ruby-0.9.2/lib/concurrent/atom.rb
, line 97 the ECONNREFUSED
exception created in dynamoid-1.0.0/lib/dynamoid/adapter.rb
, line 20 is catched and ignored.
Therefore, when I cannot connect to an endpoint, I get an undefined method
include?' for nil:NilClass`
To reproduce, just try to save any object with an endpoint of "localhost:3000" without DynamoDB running.
I am not sure if this should be fixed in concurrent-ruby or here. Maybe it would be a good idea, to query the tables first, then swap it in.
It seems that the range query is now working only with
It may be caused by explicit type-cast in range_hash method
and failure in range_query construction
Dynamoid sets the MAX_ITEM_SIZE
value to 64 KB. However, the current limit is 400 KB. Please see the Limits in DynamoDB documentation.
Also, the #write_attribute
method within Fields
incorrectly calculates this limit.
def write_attribute(name, value)
if (size = value.to_s.size) > MAX_ITEM_SIZE
Dynamoid.logger.warn "DynamoDB can't store items larger than #{MAX_ITEM_SIZE} and the #{name} field has a length of #{size}."
end
...
The calculation for the warning only takes into account the size of a single value. However the item limit is based upon the sum of all key value pairs within the item. If you wanted to keep the warning, to be accurate, the calculation would have to be something like:
attributes.map{|k,v| "#{k}#{v}"}.join.size
I can submit a pull request if you let me know the direction you would like to take.
Does Dynamoid currently support working with nested attributes
I failed to find anything in the documentation/README (or specs) that pertains to that.
Dynamoid translates its field types to DynamoDB attribute types, in Dynamoid::Persistence#dynamo_type
.
The mapping right now is overly simple: all fields map either to a numeric or a string attribute. This maps container fields (:array
and :set
) to a string also.
AWS SDK v2 offers a better selection of attribute types that map much more closely to Dynamoid's field types. Dynamoid should support this.
Some specific ideas:
:array
field => List attribute:set
field type should be split into :number_set
and :string_set
and mapped to its respective DynamoDB attribute type.For backwards compatibility, Persistence#undump_field
should check what value type AWS SDK returns, and undump the field using the old (string) behavior if the existing value is a string.
class User
include Dynamoid::Document
field :age, :integer
validates :numericality => {:allow_blank => true, :only_integer => true }
end
# This is raises an exception about "abc" not being an integer
u = User.new(:age => "abc")
ActiveRecord attempts to typecast and if it fails it stores nil. It also stores age_before_type_cast. Something similar needs to be done for Dynamoid.
More info here
http://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/BeforeTypeCast.html
At present, I'm hacking around trying to figure out how to test my Rails app built on Dyanmoid/Dynamo... not intuitive.
Any suggestions from the pros? Thanks!
(I'm happy to consolidate suggestions and add to the README!)
I'm looking to split my data into time-sliced tables.
Before I do any work on this I wanted to ask I you would be interested in merging pull request that would allow dynamic tables names for a model (say, defined at runtime by a lambda).
Has anyone been able to get this to run in Rails 5? I just get "There was an error while trying to load the gem 'dynamoid'. (Bundler::GemRequireError)" when I run rails c or rails s.
The error message is unhelpful.
As described at #4 (comment). If there are fields
in DynamoDB records which are not declared in Dynamoid model then, it raises exception. Ideally, It should ignore those fields and materialize the model regardlessly.
# @example
# class User
# include Dynamoid::Document
# field :email, :string
# field :age, :integer
# field :gender, :string
# field :rank :number
# table :key => :email
# global_secondary_index :hash_key => :age, :range_key => :gender
# end
# User.find_all_by_secondary_index(:age => 5, :range => {"rank.lte" => 10})
:range_key => :gender
should instead be :range_key => :rank
.User.find_all_by_secondary_index(:age => 5, :range => {"rank.lte" => 10})
, asUser.find_all_by_secondary_index({:age => 5}, :range => {"rank.lte" => 10})
Timestamp fields may not compare equal after round-trip to DynamoDB. The root cause is that Time.at(some_time_obj.to_f)
is not always equal to some_time_obj
, in at least MRI and JRuby.
For now, the best workaround is to compare timestamps with the aid of an epsilon.
Another solution is for Dynamoid to use Time#_dump
and Time::_load
to persist timestamps, but we must take care to not break backward compatibility with existing records in DynamoDB.
User.count == 9
User.all.count == 24
Last query is working as expected But first one gives wrong result
Hi,
I try this gem few months ago. I follow the examples in the documentation (readme) to create dynamoDB tables. But at the end of each month i get an expensive cost (+200$) caused by the tables created with your examples with 400 for read and write capacity.
(I forget to delete these tables because i change the region in AWS and the tables ware hidden :-( ) .
I suggest to change the capacity in your documentation to a lower value like 1 or 2. Users can adjust this value if needed.
class User
include Dynamoid::Document
table :name => :awesome_users, :key => :user_id, :read_capacity => 2, :write_capacity => 2
end
Thanks
I have already installed dynamoid gem but still getting uninitialized constant error
pi@raspberrypi:~/waterpi-web $ ruby app.rb
/home/pi/waterpi-web/models/item.rb:2:in <class:Item>': uninitialized constant Item::Dynamoid (NameError) from /home/pi/waterpi-web/models/item.rb:1:in
<top (required)>'
from /home/pi/waterpi-web/boot.rb:22:in require' from /home/pi/waterpi-web/boot.rb:22:in
block (2 levels) in <top (required)>'
from /home/pi/waterpi-web/boot.rb:22:in each' from /home/pi/waterpi-web/boot.rb:22:in
block in <top (required)>'
from /home/pi/waterpi-web/boot.rb:21:in each' from /home/pi/waterpi-web/boot.rb:21:in
<top (required)>'
from /home/pi/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /home/pi/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from app.rb:3:in `
souce code- https://github.com/demirhanaydin/waterpi-web
asw-sdk-ruby-record
is an official aws-supported gem: https://github.com/aws/aws-sdk-ruby-record
wonder if we could/should refactor dynamoid to rely on that (official gem) for much of it's persistence/indexes logic etc since it's aws maintained and likely to be kept up to date, but that might be a larger project and is certainly a tangent from this question)
This is something we need to investigate and consider.
Sorry if this is the wrong place to put this,
I am working on a project where we intend to use DynamoDB as sort of an "attribute bucket" for any sort of attributes the user can dream of. We would like to use Dynamoid because it's an excellent, full-featured ORM, however the docs don't mention any support of unspecified attributes. Requiring a code-change to add a novel attribute to an object is not feasible.
With Dynamoid, is there a way to add attributes that aren't specified in the model definition? Or am I out of luck? Or is that a feature that is intending to be added (in which case I plan to contribute)?
The save method on the object is raising this error.
Please!
Aws::DynamoDB::Errors::ValidationException: One or more parameter values were invalid: An AttributeValue may not contain an empty string
It looks like this is something Dynamoid could take care of in house. A nil or empty attribute should be omitted.
Update: I've taken a closer look and it looks as if something like DynamoidModel.new(whatever: nil, another: "")
isn't a problem. I'll have to dig deeper to see what's causing this issue.
Another update: It's specifically a where(..).any?
causing this. I have a duplicate?
method which can end up running something like this:
NotificationEventEmail.where(notification_generator_id: 1, event_status: 'send', num_dispatch_attempts: 0, recipient: "[email protected]", subject: "").any?
That can be fixed with something that removed blank attributes like this:
NotificationEventEmail.where({notification_generator_id: 1, event_status: 'send', num_dispatch_attempts: 0, recipient: "[email protected]", subject: ""}.delete_if { |k, v| v.blank? }).any?
But I think seeing as this is a quirk of the AWS SDK, this should be done by Dynamoid like it does for inserts.
A backtrace when a program uses Dynamoid (with AWS SDK v2) in a multi-threaded environment:
NoMethodError:
undefined method `list_tables' for nil:NilClass
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter/aws_sdk_v2.rb:220:in `list_tables'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:128:in `list_tables'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:42:in `benchmark'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:128:in `list_tables'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:28:in `reconnect!'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:42:in `benchmark'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:28:in `reconnect!'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:17:in `adapter'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:128:in `get_item'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:42:in `benchmark'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:128:in `get_item'
# .../dynamoid-1.0.0pre/lib/dynamoid/adapter.rb:80:in `read'
Here's what I think is happening:
Dynamoid::Adapter.get_item
.Dynamoid::Adapter.reconnect!
. Suppose thread A and B are at the start of .reconnect!
.@adapter
, and calls @adapter.connect!
(lines 26--27 of adapter.rb). Context switch to thread B.@adapter
, but does not yet call .connect!
. Context switch to thread A.list_tables
(line 28 of adapter.rb) on an adapter instance that hasn't connected yet.The console message instructing what to add to my class to index had bad syntax.
You can index this query by adding this to notificationeventemail.rb: index [:[:body, {:type=>:string}], :[:created_at, {:type=>:datetime}], :[:id, {:type=>:string}], :[:instant, {:type=>:boolean}], :[:notification_generator_id, {:type=>:integer}], :[:recipient, {:type=>:string}], :[:subject, {:type=>:string}], :[:updated_at, {:type=>:datetime}]]
I took a look at the docs, but now I'm getting a no method error for index
.
RuntimeError: Error creating email notification: undefined method `index' for NotificationEventEmail:Class | ["/Users/whatever/.rvm/gems/ruby-2.0.0-p451@itglue/gems/dynamoid-1.1.0/lib/dynamoid/finders.rb:128:in `method_missing'
In my class I've just got:
index [:instant, :notification_generator_id, :recipient, :subject, :body]
I have a problem with relations, I'm migrating an app from node to rails, unfortunately I didn't make it so naming are not really standard; I have a model Release and a model Artist
class Release
include Dynamoid::Document
belongs_to :artists, class: Artist
field :_id
field :title
end
class Artist
include Dynamoid::Document
has_many :releases, class_name: :release
field :_id
field :name
end
The problem is that my relation field in Release is named artists instead of artists_id so i can't get it to work; it would be the foreign_key field but I'm not understanding how to do it here, I gave a look at the library but I'm not so advanced.
Thanks in advance
Chris
We are using the Dynamoid Gem in our project
We are currectly want to implement Exception handling from the Dynamoid
Different types of exceptions are handled by
begin
// some code where exception may happen
rescue Exception => e
p e.message
end
For ConditionalCheckFailedException we are not able to get e.http_response.headers["x-amzn-requestid"]
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.