Skip to content

Instantly share code, notes, and snippets.

@macks
Created July 31, 2009 18:52
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 macks/159375 to your computer and use it in GitHub Desktop.
Save macks/159375 to your computer and use it in GitHub Desktop.
Bigint support for DataMapper/MySQL
# 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