Skip to content

Instantly share code, notes, and snippets.

@dkubb
Forked from MarkMT/gist:216205
Created October 24, 2009 00:01
Show Gist options
  • Save dkubb/217280 to your computer and use it in GitHub Desktop.
Save dkubb/217280 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -Ku
# encoding: utf-8
require 'rubygems'
require 'dm-core'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'mysql://localhost/dm_core_test')
class Event
include DataMapper::Resource
property :id, Serial
property :name, Text
end
DataMapper.auto_migrate!
e = Event.new(:name => 'test')
p e.save
id = e.id
e = Event.get(id)
e.name = 'test'
p e.save
__END__
OUTPUT:
~ (0.000128) SET sql_auto_is_null = 0
~ (0.000110) SET SESSION sql_mode = 'ANSI,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,TRADITIONAL'
~ (0.000183) DROP TABLE IF EXISTS `events`
~ (0.091431) SHOW TABLES LIKE 'events'
~ (0.000290) SHOW VARIABLES LIKE 'character_set_connection'
~ (0.000179) SHOW VARIABLES LIKE 'collation_connection'
~ (0.032829) CREATE TABLE `events` (`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `name` TEXT, PRIMARY KEY(`id`)) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
~ (0.000922) INSERT INTO `events` (`name`) VALUES ('test')
true
~ (0.000270) SELECT `id` FROM `events` WHERE `id` = 1 ORDER BY `id` LIMIT 1
~ (0.000189) UPDATE `events` SET `name` = 'test' WHERE `id` = 1
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment