lib/enrichment_db/db.rb in enrichment_db-0.1.13 vs lib/enrichment_db/db.rb in enrichment_db-0.1.14
- old
+ new
@@ -39,27 +39,17 @@
def self.request(db, query, values = nil)
type = request_type(query)
case type
when :select, 'select', '\d'
- get_or_request(query, values)
+ return EnrichmentDb::db_connection.exec(query, values) if values
+
+ EnrichmentDb::db_connection.exec(query)
when :insert, :drop, :delete, 'insert', 'drop', 'delete'
fail EnrichmentDb::RequestError, "Postgres method '#{type}' is unsupported"
else
fail EnrichmentDb::RequestError, "Postgres query '#{query}' is unsupported"
end
- end
-
- def self.get_or_request(query, values = nil)
- result = EnrichmentDb::Cache.get(query, values)
- return result unless result.nil?
-
- result = if values
- EnrichmentDb::db_connection.exec(query, values)
- else
- EnrichmentDb::db_connection.exec(query)
- end
- EnrichmentDb::Cache.set(query, values, result)
end
def self.request_type(query)
result = query.downcase.match(/(^(?:drop|select|insert|delete|\\d))/)
return unless result