Class RR::ProxyConnection
In: lib/rubyrep/proxy_connection.rb
Parent: Object

This class represents a remote activerecord database connection. Normally created by DatabaseProxy

Methods

Included Modules

DRbUndumped

Attributes

config  [RW]  A hash as described by ActiveRecord::Base#establish_connection
connection  [RW]  The database connection
cursors  [RW]  Hash to register cursors. Purpose:
  Objects only referenced remotely via DRb can be garbage collected.
  We register them in this hash to protect them from unintended garbage collection.
manual_primary_keys  [RW]  A hash of manually overwritten primary keys:
  • key: table_name
  • value: array of primary key names
primary_key_names_cache  [RW]  Caching the primary keys. This is a hash with
  * key: table name
  * value: array of primary key names
table_column_names  [RW]  Hash of table_name => array of column names pairs.
table_columns  [RW]  2-level Hash of table_name => column_name => Column objects.

Public Class methods

Create a session on the proxy side according to provided configuration hash. config is a hash as described by ActiveRecord::Base#establish_connection

Public Instance methods

Returns an array of column names of the given table name. The array is ordered in the sequence as returned by the database. The result is cached for higher speed.

Create a cursor for the given table.

  * +cursor_class+: should specify the Cursor class (e. g. ProxyBlockCursor or ProxyRowCursor).
  * +table+: name of the table
  * +options+: An option hash that is used to construct the SQL query. See ProxyCursor#construct_query for details.

Creates a table Call forwarded to ActiveRecord::ConnectionAdapters::SchemaStatements#create_table Provides an empty block (to prevent DRB from calling back the client)

Returns a Hash of currently registerred cursors

Deletes the specified record from the named table. values is a hash of column_name => value pairs. (Only the primary key values will be used and must be included in the hash.) Returns the number of deleted records.

Destroys the session

Destroys the provided cursor and removes it from the register

Inserts the specified records into the named table. values is a hash of column_name => value pairs.

Returns an array of primary key names for the given table_name. Caches the result for future calls. Allows manual overwrites through the Configuration options +:primary_key_names+ or :primary_key_only_limit.

Parameters:

  • table_name: name of the table
  • options: An option hash with the following valid options:
    • :raw: if true, than don‘t use manual overwrites and don‘t cache

Quotes the given value. It is assumed that the value belongs to the specified column name and table name. Caches the column objects for higher speed.

Store a cursor in the register to protect it from the garbage collector.

Returns a cusor as produced by the select_cursor method of the connection extenders.

Two modes of operation: Either

  • execute the specified query (takes precedense) OR
  • first build the query based on options forwarded to table_select_query

options is a hash with

  • :query: executes the given query
  • :type_cast: Unless explicitely disabled with false, build type casting cursor around result.
  • :table: Name of the table from which to read data. Required unless type casting is disabled.
  • further options as taken by table_select_query to build the query
  • :row_buffer_size: Integer controlling how many rows a read into memory at one time.

Reads the designated record from the database. Refer to select_cursor for details parameter description. Returns the first matching row (column_name => value hash or nil).

Reads the designated records from the database. Refer to select_cursor for details parameter description. Returns an array of matching rows (column_name => value hashes).

Returns an SQL delete query for the given table and values values is a hash of column_name => value pairs. (Only the primary key values will be used and must be included in the hash.)

Returns an SQL insert query for the given table and values. values is a hash of column_name => value pairs.

Returns an SQL query string for the given table based on the provided options. options is a hash that can contain any of the following:

  * :+from+: nil OR the hash of primary key => value pairs designating the start of the selection
  * :+exclude_starting_row+: if true, do not include the row specified by :+from+
  * :+to+: nil OR the hash of primary key => value pairs designating the end of the selection
  * :+row_keys+: an array of primary key => value hashes specify the target rows.

Returns an SQL update query.

  • table: name of the target table
  • values: a hash of column_name => value pairs
  • org_key: A hash of column_name => value pairs. If nil, use the key specified by values instead.

Updates the specified records of the specified table.

  • table: name of the target table
  • values: a hash of column_name => value pairs.
  • org_key: A hash of column_name => value pairs. If nil, use the key specified by values instead.

Returns the number of modified records.

[Validate]