Created
July 31, 2009 18:52
-
-
Save macks/159375 to your computer and use it in GitHub Desktop.
Bigint support for DataMapper/MySQL
This file contains hidden or 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
# Bigint support for DataMapper/MySQL | |
# | |
# e.g.) | |
# property :value, Bigint | |
gem 'dm-core', '0.9.11' | |
require 'dm-core' | |
require 'dm-core/adapters/mysql_adapter' | |
module DataMapper | |
module Adapters | |
class DataObjectsAdapter | |
alias property_schema_hash__without_bigint property_schema_hash | |
end | |
class MysqlAdapter | |
alias property_schema_hash__without_bigint property_schema_hash | |
def property_schema_hash(repository, property) | |
schema = property_schema_hash__without_bigint(repository, property) | |
if schema[:primitive] == 'INT' && schema[:size] && schema[:size] > 11 | |
schema[:primitive] = 'BIGINT' | |
end | |
schema | |
end | |
end | |
end | |
module Types | |
class Bigint < DataMapper::Type | |
primitive Integer | |
size 20 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment