Created
December 26, 2009 12:47
-
-
Save Antti/263943 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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