Class: PG::BasicTypeMapForQueries

### Home Classes Methods

### In Files

- lib/pg/basic_type_mapping.rb

### Parent

PG::TypeMapByClass

### Methods

- ::new

### Included Modules

- PG::BasicTypeRegistry

### Files

- LICENSE
- Manifest.txt
- POSTGRES
- README-OS_X.rdoc
- README-Windows.rdoc
- README.ja.rdoc
- README.rdoc
- errorcodes.txt

### Class/Module Index

Quicksearch

- PG
- PG::BasicTypeMapBasedOnResult
- PG::BasicTypeMapForQueries
- PG::BasicTypeMapForResults
- PG::BasicTypeMapForResults::WarningTypeMap
- PG::BasicTypeRegistry
- PG::BasicTypeRegistry::CoderMap
- PG::Coder
- PG::Coder::BinaryFormatting
- PG::CompositeCoder
- PG::Connection
- PG::Connection
- PG::Constants
- PG::CopyCoder
- PG::Error
- PG::NotAllCopyDataRetrieved
- PG::Result
- PG::Result
- PG::TextDecoder
- PG::TextDecoder::Date
- PG::TextDecoder::TimestampWithTimeZone
- PG::TextDecoder::TimestampWithoutTimeZone
- PG::TextEncoder
- PG::TextEncoder::Date
- PG::TextEncoder::TimestampWithTimeZone
- PG::TextEncoder::TimestampWithoutTimeZone
- PG::TypeMapByColumn
- Object
- Object::PGconn
- Object::PGresult

No matching classes.

# PG::BasicTypeMapForQueries

Simple set of rules for type casting common Ruby types to PostgreSQL.

OIDs of supported type casts are not hard-coded in the sources, but are retrieved from the PostgreSQL's pg_type table in PG::BasicTypeMapForQueries.new .

Query params are type casted based on the MRI internal type of the given value.

Higher level libraries will most likely not make use of this class, but use their own set of rules to choose suitable encoders and decoders.

Example:

    conn = PG::Connection.new
    # Assign a default ruleset for type casts of input and output values.
    conn.type_mapping_for_queries = PG::BasicTypeMapForQueries.new(conn)
    # Execute a query. The Integer param value is typecasted internally by PG::BinaryEncoder::Int8.
    # The format of the parameter is set to 1 (binary) and the OID of this parameter is set to 20 (int8).
    res = conn.exec_params( "SELECT $1", [5] )

### Constants

DEFAULT_ARRAY_TYPE_MAP
DEFAULT_TYPE_MAP

### Public Class Methods

new(connection) click to toggle source

    # File lib/pg/basic_type_mapping.rb, line 332
    def initialize(connection)
            @coder_maps = build_coder_maps(connection)

            populate_encoder_list
            @array_encoders_by_klass = array_encoders_by_klass
            @anyarray_encoder = coder_by_name(0, :encoder, '_any')
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.