Module: Sequel::Postgres::DatasetMethods::PreparedStatementMethods

Defined in:
lib/sequel/adapters/shared/postgres.rb

Overview

Shared methods for prepared statements when used with PostgreSQL databases.

Instance Method Summary collapse

Instance Method Details

#prepared_sqlObject



1227
1228
1229
1230
1231
1232
1233
1234
1235
# File 'lib/sequel/adapters/shared/postgres.rb', line 1227

def prepared_sql
  return @prepared_sql if @prepared_sql
  if @prepared_type == :insert && !opts[:returning]
    @opts[:returning] = insert_pk
    @opts[:returning_pk] = true
  end
  super
  @prepared_sql
end

#runObject

Override insert action to use RETURNING if the server supports it.



1219
1220
1221
1222
1223
1224
1225
# File 'lib/sequel/adapters/shared/postgres.rb', line 1219

def run
  if @prepared_type == :insert && (opts[:returning_pk] || !opts[:returning])
    fetch_rows(prepared_sql){|r| return r.values.first}
  else
    super
  end
end