Permalink
Browse files

introduce AR::ConnectionAdapters::PostgreSQL for sharing modules (wit…

…h AR-JDBC)

... 'shared' OID, ArrayParser and Cast helpers, also re-arranged Column's dependencies
  • Loading branch information...
1 parent dd16a10 commit 6822dfad31786d6c297e749e422e66b195cc70d1 @kares kares committed May 14, 2014
@@ -1,6 +1,6 @@
module ActiveRecord
module ConnectionAdapters
- class PostgreSQLColumn < Column
+ module PostgreSQL
module ArrayParser
DOUBLE_QUOTE = '"'
@@ -1,6 +1,6 @@
module ActiveRecord
module ConnectionAdapters
- class PostgreSQLColumn < Column
+ module PostgreSQL
module Cast
def point_to_string(point)
"(#{point[0]},#{point[1]})"
@@ -1,7 +1,10 @@
+require 'active_record/connection_adapters/postgresql/cast'
+
module ActiveRecord
module ConnectionAdapters
# PostgreSQL-specific extensions to column definitions in a table.
class PostgreSQLColumn < Column #:nodoc:
+
attr_accessor :array
def initialize(name, default, oid_type, sql_type = nil, null = true)
@@ -29,7 +32,7 @@ def text?
# :stopdoc:
class << self
- include PostgreSQLColumn::Cast
+ include PostgreSQL::Cast
# Loads pg_array_parser if available. String parsing can be
# performed quicker by a native extension, which will not create
@@ -40,7 +43,7 @@ class << self
include PgArrayParser
rescue LoadError
require 'active_record/connection_adapters/postgresql/array_parser'
- include PostgreSQLColumn::ArrayParser
+ include PostgreSQL::ArrayParser
end
attr_accessor :money_precision
@@ -1,8 +1,6 @@
-require 'active_record/connection_adapters/abstract_adapter'
-
module ActiveRecord
module ConnectionAdapters
- class PostgreSQLAdapter < AbstractAdapter
+ module PostgreSQL
module OID
class Type
def type; end
@@ -1,6 +1,6 @@
module ActiveRecord
module ConnectionAdapters
- class PostgreSQLAdapter < AbstractAdapter
+ module PostgreSQL
module Quoting
# Escapes binary strings for bytea input to the database.
def escape_bytea(value)
@@ -1,6 +1,6 @@
module ActiveRecord
module ConnectionAdapters
- class PostgreSQLAdapter < AbstractAdapter
+ module PostgreSQL
module ReferentialIntegrity
def supports_disable_referential_integrity? #:nodoc:
true
@@ -1,13 +1,14 @@
require 'active_record/connection_adapters/abstract_adapter'
require 'active_record/connection_adapters/statement_pool'
+
+require 'active_record/connection_adapters/postgresql/column'
require 'active_record/connection_adapters/postgresql/oid'
-require 'active_record/connection_adapters/postgresql/cast'
-require 'active_record/connection_adapters/postgresql/array_parser'
require 'active_record/connection_adapters/postgresql/quoting'
+require 'active_record/connection_adapters/postgresql/referential_integrity'
+
require 'active_record/connection_adapters/postgresql/schema_statements'
require 'active_record/connection_adapters/postgresql/database_statements'
-require 'active_record/connection_adapters/postgresql/referential_integrity'
-require 'active_record/connection_adapters/postgresql/column'
+
require 'arel/visitors/bind_visitor'
# Make sure we're using pg high enough for PGResult#values
@@ -44,6 +45,7 @@ def postgresql_connection(config)
end
module ConnectionAdapters
+
# The PostgreSQL adapter works with the native C (https://bitbucket.org/ged/ruby-pg) driver.
#
# Options:
@@ -72,6 +74,7 @@ module ConnectionAdapters
# In addition, default connection parameters of libpq can be set per environment variables.
# See http://www.postgresql.org/docs/9.1/static/libpq-envars.html .
class PostgreSQLAdapter < AbstractAdapter
+
class ColumnDefinition < ActiveRecord::ConnectionAdapters::ColumnDefinition
attr_accessor :array
end
@@ -238,8 +241,10 @@ class Table < ActiveRecord::ConnectionAdapters::Table
citext: { name: "citext" }
}
- include Quoting
- include ReferentialIntegrity
+ OID = PostgreSQL::OID #:nodoc:
+
+ include PostgreSQL::Quoting
+ include PostgreSQL::ReferentialIntegrity
include SchemaStatements
include DatabaseStatements
include Savepoints

0 comments on commit 6822dfa

Please sign in to comment.