From a6ac78c457348105896b2dc9afd707c1118b03d4 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Fri, 22 Dec 2017 08:49:25 +0100 Subject: [PATCH] Better documentation to coder param of copy related methods --- ext/pg_connection.c | 10 ++++++---- lib/pg/connection.rb | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ext/pg_connection.c b/ext/pg_connection.c index f8e4a217b..9977503d8 100644 --- a/ext/pg_connection.c +++ b/ext/pg_connection.c @@ -2560,8 +2560,9 @@ pgconn_wait_for_notify(int argc, VALUE *argv, VALUE self) * not sent (false is only possible if the connection * is in nonblocking mode, and this command would block). * - * encoder can be a PG::Coder derivation (typically PG::TextEncoder::CopyRow). - * This encodes the received data fields from an Array of Strings. Optionally + * _encoder_ can be a PG::Coder derivation (typically PG::TextEncoder::CopyRow). + * This encodes the data fields given as _buffer_ from an Array of Strings to + * PostgreSQL's COPY text format inclusive proper escaping. Optionally * the encoder can type cast the fields from various Ruby types in one step, * if PG::TextEncoder::CopyRow#type_map is set accordingly. * @@ -2673,8 +2674,9 @@ pgconn_put_copy_end(int argc, VALUE *argv, VALUE self) * if the copy is done, or +false+ if the call would * block (only possible if _async_ is true). * - * decoder can be a PG::Coder derivation (typically PG::TextDecoder::CopyRow). - * This decodes the received data fields as Array of Strings. Optionally + * _decoder_ can be a PG::Coder derivation (typically PG::TextDecoder::CopyRow). + * This decodes the received data fields from PostgreSQL's COPY text format to an + * Array of Strings. Optionally * the decoder can type cast the fields to various Ruby types in one step, * if PG::TextDecoder::CopyRow#type_map is set accordingly. * diff --git a/lib/pg/connection.rb b/lib/pg/connection.rb index bf409eea3..6c2109846 100755 --- a/lib/pg/connection.rb +++ b/lib/pg/connection.rb @@ -85,7 +85,7 @@ def self::parse_connect_args( *args ) # call-seq: - # conn.copy_data( sql ) {|sql_result| ... } -> PG::Result + # conn.copy_data( sql [, coder] ) {|sql_result| ... } -> PG::Result # # Execute a copy process for transfering data to or from the server. # @@ -109,6 +109,11 @@ def self::parse_connect_args( *args ) # of blocking mode of operation, #copy_data is preferred to raw calls # of #put_copy_data, #get_copy_data and #put_copy_end. # + # _coder_ can be a PG::Coder derivation + # (typically PG::TextEncoder::CopyRow or PG::TextDecoder::CopyRow). + # This enables encoding of data fields given to #put_copy_data + # or decoding of fields received by #get_copy_data. + # # Example with CSV input format: # conn.exec "create table my_table (a text,b text,c text,d text)" # conn.copy_data "COPY my_table FROM STDIN CSV" do