postgres.rb

Path: lib/sequel/adapters/shared/postgres.rb
Last Update: Tue Feb 01 03:28:39 +0000 2011

Methods

Public Instance methods

Apply connection settings for this connection. Currently, turns standard_conforming_strings ON if Postgres.force_standard_strings is true.

[Source]

     # File lib/sequel/adapters/shared/postgres.rb, line 117
117:       def apply_connection_settings
118:         if Postgres.force_standard_strings
119:           # This setting will only work on PostgreSQL 8.2 or greater
120:           # and we don't know the server version at this point, so
121:           # try it unconditionally and rescue any errors.
122:           execute("SET standard_conforming_strings = ON") rescue nil
123:         end
124:         if cmm = Postgres.client_min_messages
125:           execute("SET client_min_messages = '#{cmm.to_s.upcase}'")
126:         end
127:       end

Get the last inserted value for the given sequence.

[Source]

     # File lib/sequel/adapters/shared/postgres.rb, line 130
130:       def last_insert_id(sequence)
131:         sql = SELECT_CURRVAL % sequence
132:         execute(sql) do |r|
133:           val = single_value(r)
134:           return val.to_i if val
135:         end
136:       end

Get the primary key for the given table.

[Source]

     # File lib/sequel/adapters/shared/postgres.rb, line 139
139:       def primary_key(schema, table)
140:         sql = SELECT_PK[schema, table]
141:         execute(sql) do |r|
142:           return single_value(r)
143:         end
144:       end

Get the primary key and sequence for the given table.

[Source]

     # File lib/sequel/adapters/shared/postgres.rb, line 147
147:       def sequence(schema, table)
148:         sql = SELECT_SERIAL_SEQUENCE[schema, table]
149:         execute(sql) do |r|
150:           seq = single_value(r)
151:           return seq if seq
152:         end
153:         
154:         sql = SELECT_CUSTOM_SEQUENCE[schema, table]
155:         execute(sql) do |r|
156:           return single_value(r)
157:         end
158:       end

[Validate]