Class: Sq::Dbsync::Database::Postgres
- Inherits:
-
Delegator
- Object
- Delegator
- Sq::Dbsync::Database::Postgres
- Includes:
- Common
- Defined in:
- lib/sq/dbsync/database/postgres.rb
Overview
Decorator around a Sequel database object, providing some non-standard extensions required for effective extraction from Postgres.
Constant Summary collapse
- CASTS =
{ "text" => "varchar(255)", "character varying(255)" => "varchar(255)", # 255 is an arbitrary choice here. The one example we have # only has data 32 characters long in it. "character varying" => "varchar(255)", # Arbitrarily chosen precision. The default numeric type in mysql is # (10, 0), which is perhaps the most useless default I could imagine. "numeric" => "numeric(12,6)", "boolean" => "char(1)", # mysql has no single-column representation for timestamp with time zone "timestamp with time zone" => "datetime", "time without time zone" => "time", "timestamp without time zone" => "datetime", }
Constants included from Common
Instance Method Summary collapse
- #hash_schema(plan) ⇒ Object
-
#initialize(db) ⇒ Postgres
constructor
A new instance of Postgres.
- #inspect ⇒ Object
- #set_lock_timeout(seconds) ⇒ Object
Methods included from Common
#__getobj__, #__setobj__, #ensure_connection, #extract_incrementally_to_file, #extract_to_file, #name
Constructor Details
#initialize(db) ⇒ Postgres
Returns a new instance of Postgres.
32 33 34 35 |
# File 'lib/sq/dbsync/database/postgres.rb', line 32 def initialize(db) super @db = db end |
Instance Method Details
#hash_schema(plan) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sq/dbsync/database/postgres.rb', line 43 def hash_schema(plan) type_casts = plan.type_casts || {} ensure_connection result = schema(plan.source_table_name).each do |col, | [:source_db_type] ||= [:db_type] [:db_type] = cast_psql_to_mysql( [:db_type], type_casts[col.to_s] ) end Hash[result] end |
#inspect ⇒ Object
37 |
# File 'lib/sq/dbsync/database/postgres.rb', line 37 def inspect; "#<Database::Postgres #{opts[:database]}>"; end |
#set_lock_timeout(seconds) ⇒ Object
39 40 41 |
# File 'lib/sq/dbsync/database/postgres.rb', line 39 def set_lock_timeout(seconds) # Unimplemented end |