Skip to content

Instantly share code, notes, and snippets.

@solnic
Created March 3, 2011 19:48
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 solnic/853367 to your computer and use it in GitHub Desktop.
Save solnic/853367 to your computer and use it in GitHub Desktop.
require 'dm-migrations'
require 'dm-types'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, "mysql://root@localhost/test")
class A
include DataMapper::Resource
storage_names[:default] = 'A'
property :id, Serial
property :e, Enum[:a, :b, :c]
end
DataMapper.finalize
DataMapper.auto_migrate!
A.create(:e => :a)
p A.find.first
p A.properties
~ (0.000101) SET sql_auto_is_null = 0
~ (0.000085) SET SESSION sql_mode = 'ANSI,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,TRADITIONAL'
~ (0.596332) DROP TABLE IF EXISTS `A`
~ (0.130307) SHOW TABLES LIKE 'A'
~ (0.000103) 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.000626) SHOW VARIABLES LIKE 'character_set_connection'
~ (0.000609) SHOW VARIABLES LIKE 'collation_connection'
~ (1.055730) CREATE TABLE `A` (`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `e` INTEGER, PRIMARY KEY(`id`)) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
~ (0.090454) INSERT INTO `A` (`e`) VALUES (1)
~ (0.000329) SELECT `id`, `e` FROM `A` ORDER BY `id`
#<A @id=1 @e=:a>
[#<DataMapper::Property::Serial @model=A @name=:id>, #< @model=A @name=:e>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment