lib/og/connection.rb in og-0.10.0 vs lib/og/connection.rb in og-0.11.0

- old
+ new

@@ -1,20 +1,20 @@ # * George Moschovitis <gm@navel.gr> # (c) 2004-2005 Navel, all rights reserved. -# $Id: connection.rb 254 2005-02-10 12:44:05Z gmosx $ +# $Id: connection.rb 265 2005-02-24 08:46:54Z gmosx $ -class Og; +module Og; require 'glue/property' require 'glue/array' require 'glue/time' # A Connection to the Database. This file defines the skeleton # functionality. A backend specific implementation file (driver) # implements all methods. # -# == Future +# === Future # # - support caching. # - support prepared statements. class Connection @@ -39,11 +39,10 @@ end # Close the connection to the database. def close - @store.close Logger.debug "Closed DB connection." if $DBG end # Create the managed object table. The properties of the # object are mapped to the table columns. Additional sql relations @@ -281,14 +280,15 @@ if klass.respond_to?(:og_pre_delete) klass.og_pre_delete(self, oid) end # TODO: implement this as stored procedure? naaah. + # TODO: also handle many_to_many relations. transaction do |tx| tx.exec "DELETE FROM #{klass::DBTABLE} WHERE oid=#{oid}" - if cascade and klass.__meta.include?(:has) - klass.__meta[:has].each do |dclass, linkback| + if cascade and klass.__meta.include?(:descendants) + klass.__meta[:descendants].each do |dclass, linkback| tx.exec "DELETE FROM #{dclass::DBTABLE} WHERE #{linkback}=#{oid}" end end end end