lib/swift/adapter.rb in swift-0.4.3 vs lib/swift/adapter.rb in swift-0.5.0

- old
+ new

@@ -1,15 +1,9 @@ module Swift - #-- - # TODO: Still not convinced all and first are necessary. class Adapter attr_reader :options - def identity_map - @identity_map ||= IdentityMap.new - end - def get scheme, keys relation = scheme.new(keys) prepare_get(scheme).execute(*relation.tuple.values_at(*scheme.header.keys)).first end @@ -17,11 +11,12 @@ where = "where #{exchange_names(scheme, conditions)}" unless conditions.empty? prepare(scheme, "select * from #{scheme.store} #{where}").execute(*binds, &block) end def first scheme, conditions = '', *binds, &block - all(scheme, "#{conditions} limit 1", *binds, &block).first + where = "where #{exchange_names(scheme, conditions)}" unless conditions.empty? + prepare(scheme, "select * from #{scheme.store} #{where} limit 1").execute(*binds, &block).first end def create scheme, *relations statement = prepare_create(scheme) relations.map do |relation| @@ -36,10 +31,11 @@ def update scheme, *relations statement = prepare_update(scheme) relations.map do |relation| relation = scheme.new(relation) unless relation.kind_of?(scheme) statement.execute(*relation.tuple.values_at(*scheme.header.updatable, *scheme.header.keys)) + relation end end def destroy scheme, *relations statement = prepare_destroy(scheme) @@ -111,9 +107,10 @@ when Type::Integer then attribute.serial ? 'serial' : 'integer' when Type::Float then 'float' when Type::BigDecimal then 'numeric' when Type::Time then 'timestamp' when Type::Boolean then 'boolean' + when Type::IO then 'blob' else 'text' end end end # Adapter end # Swift