Skip to content

Commit

Permalink
introduce AR::ConnectionAdapters::PostgreSQL for sharing modules (wit…
Browse files Browse the repository at this point in the history
…h AR-JDBC)

... 'shared' OID, ArrayParser and Cast helpers, also re-arranged Column's dependencies
  • Loading branch information
kares committed May 14, 2014
1 parent dd16a10 commit 6822dfa
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ActiveRecord
module ConnectionAdapters
class PostgreSQLColumn < Column
module PostgreSQL
module ArrayParser

DOUBLE_QUOTE = '"'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ActiveRecord
module ConnectionAdapters
class PostgreSQLColumn < Column
module PostgreSQL
module Cast
def point_to_string(point)
"(#{point[0]},#{point[1]})"
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter < AbstractAdapter
module PostgreSQL
module ReferentialIntegrity
def supports_disable_referential_integrity? #:nodoc:
true
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6822dfa

Please sign in to comment.