Skip to content

Instantly share code, notes, and snippets.

@Antti
Created December 26, 2009 12:47
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 Antti/263943 to your computer and use it in GitHub Desktop.
Save Antti/263943 to your computer and use it in GitHub Desktop.
%w[dm-core dm-ar-finders data_objects do_sqlite3].each{|g| gem g}
require 'dm-core'
require 'dm-ar-finders'
DataMapper.setup(:default, 'sqlite3::memory:')
DataObjects::Sqlite3.logger = DataObjects::Logger.new(STDOUT, :debug)
class Bug
include DataMapper::Resource
property :id, Serial
property :name, String
property :bugged_field, String, :field => "bugg"
property :not_a_bug, String
end
DataMapper.auto_migrate!
Bug.create(:name =>"BugName1", :bugged_field => "BuggedField1", :not_a_bug => "Not a bug1")
p Bug.find_by_sql("SELECT * FROM bugs")
=begin
Sat, 26 Dec 2009 12:45:08 GMT ~ debug ~ (0.000037) SELECT sqlite_version(*)
Sat, 26 Dec 2009 12:45:08 GMT ~ debug ~ (0.000104) DROP TABLE IF EXISTS "bugs"
Sat, 26 Dec 2009 12:45:08 GMT ~ debug ~ (0.000011) PRAGMA table_info("bugs")
Sat, 26 Dec 2009 12:45:08 GMT ~ debug ~ (0.000370) CREATE TABLE "bugs" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(50), "bugg" VARCHAR(50), "not_a_bug" VARCHAR(50))
Sat, 26 Dec 2009 12:45:08 GMT ~ debug ~ (0.000042) INSERT INTO "bugs" ("name", "bugg", "not_a_bug") VALUES ('BugName1', 'BuggedField1', 'Not a bug1')
Sat, 26 Dec 2009 12:45:08 GMT ~ debug ~ (0.000028) SELECT * FROM bugs
[#<Bug @id=1 @name="BugName1" @bugged_field=nil @not_a_bug="BuggedField1">]
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment