Skip to content

Commit

Permalink
Better documentation to coder param of copy related methods
Browse files Browse the repository at this point in the history
  • Loading branch information
larskanis committed Dec 22, 2017
1 parent c3caa96 commit a6ac78c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 6 additions & 4 deletions ext/pg_connection.c
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
7 changes: 6 additions & 1 deletion lib/pg/connection.rb
Expand Up @@ -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.
#
Expand All @@ -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
Expand Down

0 comments on commit a6ac78c

Please sign in to comment.