Class Og::Backend
In: lib/og/backend.rb
Parent: Object

Abstract backend. A backend communicates with the RDBMS. This is the base class for the various backend implementations.

Attributes

conn  [RW]  The actual connection to the database

Public Class methods

Intitialize the connection to the RDBMS.

Public Instance methods

Close the connection to the RDBMS.

Utilities

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Class methods

Encode the name of the klass as an sql safe string. The Module separators are replaced with _ and NOT stripped out so that we can convert back to the original notation if needed. The leading module if available is removed.

Precompile the code to read objects of the given class from the backend. In order to allow for changing field/attribute orders we have to use a field mapping hash.

Precompile the insert code for the given class. The generated code sets the oid when inserting!

Precompile the update code for the given class. Ignore the oid when updating!

The name of the join table for the two given classes.

Returns the props that will be included in the insert query. For some backends the oid should be stripped.

The name of the SQL table where objects of this class are stored.

Connection methods.

Public Class methods

Public Instance methods

Commit a transaction.

Create the fields that correpsond to the klass properties. The generated fields array is used in create_table. If the property has an :sql metadata this overrides the default mapping. If the property has an :extra_sql metadata the extra sql is appended after the default mapping.

Create the managed object table. The properties of the object are mapped to the table columns. Additional sql relations and constrains are created (indicices, sequences, etc).

Deserialize all rows of the resultset.

Deserialize one row of the resultset.

Drop the managed object table

Execute an SQL query, no result returned.

Return a single integer value from the resultset.

Execute an SQL query and return the result.

Rollback transaction.

Execute an SQL query, no result returned. Wrapped in a rescue block.

Execute an SQL query and return the result. Wrapped in a rescue block.

Start a new transaction.

Check if it is a valid resultset.