lib/db/sync/model.rb in db-sync-0.0.4 vs lib/db/sync/model.rb in db-sync-0.0.5
- old
+ new
@@ -21,9 +21,20 @@
else
attribute_names.sort
end
end
+ def self.ordered_attributes
+ pkey + (attribute_names - pkey).sort
+ end
+
def self.records
- order(pkey)
+ attributes_order = ordered_attributes
+ order(pkey).map do |record|
+ res = {}
+ attributes_order.each do |key|
+ res[key] = record[key]
+ end
+ res
+ end
end
end