Skip to content

Instantly share code, notes, and snippets.

@lance
Created January 11, 2012 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lance/1596396 to your computer and use it in GitHub Desktop.
Save lance/1596396 to your computer and use it in GitHub Desktop.
$ ruby spec.rb
~ (0.000990) SET backslash_quote = off
~ (0.019931) SET standard_conforming_strings = on
~ (0.000291) SET client_min_messages = warning
~ (0.021172) SELECT current_schema()
~ (0.021269) SELECT COUNT(*) FROM "information_schema"."tables" WHERE "table_type" = 'BASE TABLE' AND "table_schema" = 'public' AND "table_name" = 'test_dms'
~ (0.001382) SELECT COUNT(*) FROM "information_schema"."tables" WHERE "table_type" = 'BASE TABLE' AND "table_schema" = 'public' AND "table_name" = 'testings'
~ (0.001239) SELECT COUNT(*) FROM "information_schema"."tables" WHERE "table_type" = 'BASE TABLE' AND "table_schema" = 'public' AND "table_name" = 'tests'
~ (0.010847) SELECT version()
~ (0.000127) SET client_min_messages = warning
~ (0.000418) DROP TABLE IF EXISTS "test_dms"
~ (0.000226) RESET client_min_messages
~ (0.000143) SET client_min_messages = warning
~ (0.001449) SELECT COUNT(*) FROM "information_schema"."tables" WHERE "table_type" = 'BASE TABLE' AND "table_schema" = 'public' AND "table_name" = 'test_dms'
~ (0.254778) CREATE TABLE "test_dms" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP, "created_on" DATE, "updated_at" TIMESTAMP, "updated_on" DATE, PRIMARY KEY("id"))
~ (0.000447) RESET client_min_messages
~ (0.000189) SET client_min_messages = warning
~ (0.000241) DROP TABLE IF EXISTS "testings"
~ (0.000149) RESET client_min_messages
~ (0.000151) SET client_min_messages = warning
~ (0.002086) SELECT COUNT(*) FROM "information_schema"."tables" WHERE "table_type" = 'BASE TABLE' AND "table_schema" = 'public' AND "table_name" = 'testings'
~ (0.003325) CREATE TABLE "testings" ("test_dm_id" INTEGER NOT NULL, "test_id" INTEGER NOT NULL, PRIMARY KEY("test_dm_id", "test_id"))
~ (0.001733) CREATE INDEX "index_testings_test" ON "testings" ("test_id")
~ (0.001475) CREATE INDEX "index_testings_test_dm" ON "testings" ("test_dm_id")
~ (0.000244) RESET client_min_messages
~ (0.000318) SET client_min_messages = warning
~ (0.000130) DROP TABLE IF EXISTS "tests"
~ (0.000166) RESET client_min_messages
~ (0.000095) SET client_min_messages = warning
~ (0.001461) SELECT COUNT(*) FROM "information_schema"."tables" WHERE "table_type" = 'BASE TABLE' AND "table_schema" = 'public' AND "table_name" = 'tests'
~ (0.003135) CREATE TABLE "tests" ("id" SERIAL NOT NULL, PRIMARY KEY("id"))
~ (0.000210) RESET client_min_messages
~ (0.003759) SELECT COUNT(*) FROM "information_schema"."table_constraints" WHERE "constraint_type" = 'FOREIGN KEY' AND "table_schema" = 'public' AND "table_name" = 'testings' AND "constraint_name" = 'testings_test_dm_fk'
~ (0.036113) ALTER TABLE "testings" ADD CONSTRAINT "testings_test_dm_fk" FOREIGN KEY ("test_dm_id") REFERENCES "test_dms" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
~ (0.003150) SELECT COUNT(*) FROM "information_schema"."table_constraints" WHERE "constraint_type" = 'FOREIGN KEY' AND "table_schema" = 'public' AND "table_name" = 'testings' AND "constraint_name" = 'testings_test_fk'
~ (0.002098) ALTER TABLE "testings" ADD CONSTRAINT "testings_test_fk" FOREIGN KEY ("test_id") REFERENCES "tests" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
~ (0.012370) INSERT INTO "tests" DEFAULT VALUES RETURNING "id"
~ (0.000711) INSERT INTO "tests" DEFAULT VALUES RETURNING "id"
spec.rb:40:in `dump': can't dump hash with default proc (TypeError)
from spec.rb:40
# Trying to replicate http://datamapper.lighthouseapp.com/projects/20609-datamapper/tickets/470-memcaching-can-t-marshal-dm-objects#ticket-470-19
require 'rubygems'
require 'data_mapper'
#require 'dm-core'
#require 'dm-migrations'
#require 'dm-timestamps'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'postgres://test:test@localhost/test') # createdb test
class TestDm
include DataMapper::Resource
property :id, Serial
property :created_at, DateTime
property :created_on, Date
property :updated_at, DateTime
property :updated_on, Date
has n, :tests, :through => :testing
has n, :testing
end
class Testing
include DataMapper::Resource
belongs_to :test_dm, :key => true
belongs_to :test, :key => true
end
class Test
include DataMapper::Resource
property :id, Serial
has n, :testing
end
DataMapper.finalize
DataMapper.auto_migrate!
test = Test.create.tap do |t|
t.testing.create(:test => Test.create)
end
puts Marshal.load(Marshal.dump(test)).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment