Skip to content

Instantly share code, notes, and snippets.

View whoahbot's full-sized avatar

Dan Herrera whoahbot

  • Portland, Oregon
View GitHub Profile
diff --git a/lib/dm-core/spec/adapter_shared_spec.rb b/lib/dm-core/spec/adapter_shared_spec.rb
index 87c9dd3..e61e301 100644
--- a/lib/dm-core/spec/adapter_shared_spec.rb
+++ b/lib/dm-core/spec/adapter_shared_spec.rb
@@ -90,6 +90,12 @@ share_examples_for 'An Adapter' do
@heffalump.id.should == id
end
+ it 'should update altered fields' do
+ @heffalump.color = 'violet'
                                                        user     system      total        real
Create 1000 posts with DM and Redis                 0.390000   0.130000   0.520000 (  0.798371)
Create 1000 posts with DM and Postgres              0.430000   0.060000   0.490000 (  1.276239)
Create 1000 posts with RedisClient                  0.190000   0.150000   0.340000 (  0.555850)
                                                        user     system      total        real
Fetch the 500th post with DM and Redis              0.000000   0.000000   0.000000 (  0.003334)
Fetch the 500th post's text with DM and Postgres    0.000000   0.000000   0.000000 (  0.002007)
Fetch the 500th post's text with RedisClient        0.000000   0.000000   0.000000 (  0.000456)
diff --git a/dm-validations/lib/dm-validations/validators/uniqueness_validator.rb b/dm-validations/lib/dm-validations/validators/uniquen
index 16fc786..6bec021 100644
--- a/dm-validations/lib/dm-validations/validators/uniqueness_validator.rb
+++ b/dm-validations/lib/dm-validations/validators/uniqueness_validator.rb
@@ -22,8 +22,11 @@ module DataMapper
repository_name = target.repository.name
+ fields = target.model.key.dup
+ fields << target.model.properties[field_name]
require "moneta"
require 'moneta/redis'
module DataMapper
# Tracks objects to help ensure that each object gets loaded only once.
# See: http://www.martinfowler.com/eaaCatalog/identityMap.html
class IdentityMap < Moneta::Redis
extend Deprecate
module PersistentIdentityMap
def self.included(base)
base.extend(ResourceClassMethods)
end
def _dump(depth)
marshaled_properties = properties.inject({}) do |h, p|
h[p.instance_variable_name] = p.get!(self)
h
end
source 'http://rubygems.org'
RAILS_VERSION = '~> 3.0.0.beta4'
DM_VERSION = '~> 1.0.0'
RSPEC_VERSION = '~> 2.0.0.beta.13'
gem 'activesupport', RAILS_VERSION, :require => 'active_support'
gem 'actionpack', RAILS_VERSION, :require => 'action_pack'
gem 'actionmailer', RAILS_VERSION, :require => 'action_mailer'
gem 'railties', RAILS_VERSION, :require => 'rails'
select
s.relname,
s.seq_tup_read + s.idx_tup_fetch usage,
(s.idx_tup_fetch/s.seq_tup_read::float)::decimal(18,4) index_ratio,
s.seq_tup_read, s.idx_tup_fetch,
s.seq_scan, s.n_live_tup,
((io.heap_blks_hit + io.idx_blks_hit)/((io.heap_blks_read + io.idx_blks_read)::float))::decimal(18,4) cache_hit_ratio
FROM pg_stat_user_tables s
INNER JOIN pg_statio_user_tables io
ON s.relid = io.relid
@whoahbot
whoahbot / statement.json
Created March 27, 2012 22:11
example statement json
{
"account_number":0123456789,
"period_start":YYMMDD,
"period_end":YYMMDD,
"starting_balance":9999.99,
"account_balance":9999.99,
"interest_rate":99.99,
"apy":99.99,
"interest_paid":99.99
}
@whoahbot
whoahbot / gist:2815883
Created May 27, 2012 20:58
Typhoeus require
test → pwd
/Users/whoahbot/code/test
test → ls
Gemfile Gemfile.lock
test → cat Gemfile
gem 'typhoeus', '0.4.0'
test → bundle show
Gems included by the bundle:
* activesupport (3.2.3)
* bundler (1.1.1)
@whoahbot
whoahbot / toQueryString.js
Created June 28, 2012 17:17
Change for serializing arrays to query params in MooTools.
Object.toQueryString({'buh':[1,2]});
"buh[0]=1&buh[1]=2"
On the server side, it looks like:
buh = {0 => 1, 1 => 2}
And we have to do buh.values in order to get it to return an array.