The PostgreSQL adapter works both with the C-based (www.postgresql.jp/interfaces/ruby/) and the Ruby-base (available both as gem and from rubyforge.org/frs/?group_id=234&release_id=1145) drivers.
Options:
- :host — Defaults to localhost
- :port — Defaults to 5432
- :username — Defaults to nothing
- :password — Defaults to nothing
- :database — The name of the database. No default, must be provided.
- :schema_order — An optional schema order string that is using in a SET search_path TO <schema_order> call on connection.
Methods
- adapter_name
- begin_db_transaction
- columns
- commit_db_transaction
- delete
- execute
- insert
- quote
- quote_column_name
- rollback_db_transaction
- select_all
- select_one
- update
Public Instance methods
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 108
108: def adapter_name()
109: 'PostgreSQL'
110: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 92
92: def begin_db_transaction() execute "BEGIN" end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 67
67: def columns(table_name, name = nil)
68: table_structure(table_name).inject([]) do |columns, field|
69: columns << Column.new(field[0], field[2], field[1])
70: columns
71: end
72: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 93
93: def commit_db_transaction() execute "COMMIT" end
Alias for update
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 80
80: def execute(sql, name = nil)
81: log(sql, name, @connection) { |connection| connection.query(sql) }
82: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 74
74: def insert(sql, name = nil, pk = nil, id_value = nil)
75: execute(sql, name = nil)
76: table = sql.split(" ", 4)[2]
77: return id_value || last_insert_id(table, pk)
78: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 96
96: def quote(value, column = nil)
97: if value.class == String && column && column.type == :binary
98: quote_bytea(value)
99: else
100: super
101: end
102: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 104
104: def quote_column_name(name)
105: return "\"#{name}\""
106: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 94
94: def rollback_db_transaction() execute "ROLLBACK" end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 58
58: def select_all(sql, name = nil)
59: select(sql, name)
60: end
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 62
62: def select_one(sql, name = nil)
63: result = select(sql, name)
64: result.nil? ? nil : result.first
65: end
This method is also aliased as
delete
[ show source ]
# File vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 84
84: def update(sql, name = nil)
85: result = nil
86: log(sql, name, @connection) { |connection| result = connection.exec(sql) }
87: result.cmdtuples
88: end