lib/og/connection.rb in og-0.13.0 vs lib/og/connection.rb in og-0.14.0

- old
+ new

@@ -1,8 +1,8 @@ # * George Moschovitis <gm@navel.gr> # (c) 2004-2005 Navel, all rights reserved. -# $Id: connection.rb 281 2005-03-10 12:24:14Z gmosx $ +# $Id: connection.rb 326 2005-03-28 11:07:17Z gmosx $ module Og; require 'glue/property' require 'glue/array' @@ -10,14 +10,14 @@ # A Connection to the Database. This file defines the skeleton # functionality. A backend specific implementation file (driver) # implements all methods. # -# === Future -# +#-- # - support caching. # - support prepared statements. +#++ class Connection # The Og database object. @@ -137,10 +137,16 @@ def read_int(res, idx = 0) raise 'Not implemented!' end + # Get a row from the resultset. + + def get_row(res) + return res + end + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # :section: Managed object methods. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Save an object to the database. Insert if this is a new object or @@ -185,10 +191,11 @@ klass = obj_or_oid.class unless klass exec "UPDATE #{klass::DBTABLE} SET #{update_sql} WHERE oid=#{oid}" end alias_method :pupdate, :update_properties + alias_method :update_propery, :update_properties # Load an object from the database. # # Input: # oid = the object oid, OR the object name. @@ -280,11 +287,11 @@ klass = obj_or_oid.class unless klass # this is a class callback! if klass.respond_to?(:og_pre_delete) - klass.og_pre_delete(self, oid) + klass.og_pre_delete(self, obj_or_oid) end # TODO: implement this as stored procedure? naaah. # TODO: also handle many_to_many relations. @@ -296,9 +303,23 @@ end end end end alias_method :delete!, :delete - + + protected + + # Handles an adapter exception. + + def handle_db_exception(ex, sql = nil) + Logger.error "DB error #{ex}, [#{sql}]" + Logger.error ex.backtrace.join("\n") + raise SqlException.new(ex, sql) if Og.raise_db_exceptions + + # FIXME: should return :error or something. + + return nil + end + end end