Sha256: 0712ab4fa5a1e62df4789fa425bc41c75f9d3eb18cc25cf844de4767f11174d7
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
module DataMapper module Is::Reflective module SqliteAdapter include DataMapper def storages sql = <<-SQL SELECT name FROM sqlite_master WHERE type = 'table' AND NOT name = 'sqlite_sequence' SQL select(Ext::String.compress_lines(sql)) end private def reflective_query_storage storage select('PRAGMA table_info(?)', storage) end def reflective_field_name field field.name end def reflective_primitive field field.type.gsub(/\(\d+\)/, '') end def reflective_attributes field, attrs = {} if field.pk != 0 attrs[:key] = true attrs[:serial] = true if supports_serial? end attrs[:allow_nil] = field.notnull == 0 attrs[:default] = field.dflt_value[1..-2] if field.dflt_value if field.type.upcase == 'TEXT' attrs[:length] = Property::Text.length else ergo = field.type.match(/\((\d+)\)/) size = ergo && ergo[1].to_i attrs[:length] = size if size end attrs end def reflective_lookup_primitive primitive p = primitive.upcase return Integer if p == 'INTEGER' return Float if p == 'REAL' || p == 'NUMERIC' return Property::Text if p == 'TEXT' super(primitive) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dm-is-reflective-1.0.1 | lib/dm-is-reflective/is/adapters/sqlite_adapter.rb |
dm-is-reflective-1.0.1.rc | lib/dm-is-reflective/is/adapters/sqlite_adapter.rb |