Created
January 13, 2009 15:46
-
-
Save felix/46493 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
require 'rubygems' | |
if (local_gem_dir = File.join(File.dirname(__FILE__), 'gems')) | |
Gem.clear_paths; Gem.path.unshift(local_gem_dir) | |
else | |
puts 'not gonna load local gems' | |
end | |
require 'dm-core' | |
DataMapper.setup(:default, 'mysql://localhost/dm_core_test') | |
class Foo | |
include DataMapper::Resource | |
property :id, Integer, :serial => true | |
property :name, String | |
property :description, Text | |
end | |
Foo.auto_migrate! | |
foo = Foo.create(:name => 'ฝรั่ง') | |
farang = Foo.get(foo.id) | |
puts farang.name | |
bar = Foo.create(:description => 'ชาวตะวันตก') | |
westerner = Foo.get(bar.id) | |
puts westerner.description |
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
387 Query SET NAMES utf8 | |
387 Query SET sql_auto_is_null = 0 | |
387 Query SET SESSION sql_mode = 'ANSI,NO_AUTO_VALUE_ON_ZERO,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,TRADITIONAL' | |
387 Query DROP TABLE IF EXISTS `foos` | |
387 Query SELECT COUNT(*) FROM `information_schema`.`tables` WHERE `table_type` = 'BASE TABLE' AND `table_schema` = 'dm_core_test' AND `table_name` = 'foos' | |
387 Query SHOW VARIABLES WHERE `variable_name` = 'character_set_connection' | |
387 Query SHOW VARIABLES WHERE `variable_name` = 'collation_connection' | |
387 Query CREATE TABLE `foos` (`id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(50), `description` TEXT, PRIMARY KEY(`id`)) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci | |
387 Query INSERT INTO `foos` (`name`) VALUES ('ฝรั่ง') |
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
/home/felix/Projects/tomato/gems/gems/data_objects-0.9.10.1/lib/data_objects/quoting.rb:53:in `quote_value': Don't know how to quote #<Foo id=1 name="\340\270\235\340\270\243\340\270\261\340\271\210\340\270\207" description=nil> (RuntimeError) | |
from /home/felix/Projects/tomato/gems/gems/data_objects-0.9.10.1/lib/data_objects/quoting.rb:27:in `escape_sql' | |
from /home/felix/Projects/tomato/gems/gems/data_objects-0.9.10.1/lib/data_objects/quoting.rb:26:in `gsub!' | |
from /home/felix/Projects/tomato/gems/gems/data_objects-0.9.10.1/lib/data_objects/quoting.rb:26:in `escape_sql' | |
from /home/felix/Projects/tomato/gems/gems/dm-core-0.9.9/lib/dm-core/adapters/data_objects_adapter.rb:66:in `execute_reader' | |
from /home/felix/Projects/tomato/gems/gems/dm-core-0.9.9/lib/dm-core/adapters/data_objects_adapter.rb:66:in `read_one' | |
from /home/felix/Projects/tomato/gems/gems/dm-core-0.9.9/lib/dm-core/adapters/data_objects_adapter.rb:173:in `with_connection' | |
from /home/felix/Projects/tomato/gems/gems/dm-core-0.9.9/lib/dm-core/adapters/data_objects_adapter.rb:61:in `read_one' | |
from /home/felix/Projects/tomato/gems/gems/dm-core-0.9.9/lib/dm-core/repository.rb:72:in `read_one' | |
from /home/felix/Projects/tomato/gems/gems/dm-core-0.9.9/lib/dm-core/model.rb:263:in `first' | |
from /home/felix/Projects/tomato/gems/gems/dm-core-0.9.9/lib/dm-core/model.rb:244:in `get' | |
from encoding.rb:30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment