Class: PG::BasicTypeMapForResults::WarningTypeMap
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::PG::TypeMapInRuby ,
::PG::TypeMap
|
|
Instance Chain:
|
|
Inherits: |
PG::TypeMapInRuby
|
Defined in: | lib/pg/basic_type_map_for_results.rb |
Class Method Summary
- .new(typenames) ⇒ WarningTypeMap constructor
Instance Attribute Summary
::PG::TypeMap::DefaultTypeMappable
- Included
#default_type_map | Returns the default |
#default_type_map= | Set the default |
Instance Method Summary
::PG::TypeMapInRuby
- Inherited
#typecast_copy_get | Cast a field string received by Connection#get_copy_data. |
#typecast_query_param | Cast a field string for transmission to the server. |
#typecast_result_value | Retrieve and cast a field of the given result. |
::PG::TypeMap::DefaultTypeMappable
- Included
#with_default_type_map | Set the default |
Constructor Details
.new(typenames) ⇒ WarningTypeMap
# File 'lib/pg/basic_type_map_for_results.rb', line 74
def initialize(typenames) @already_warned = {} @typenames_by_oid = typenames end
Instance Method Details
#typecast_result_value(result, _tuple, field)
[ GitHub ]# File 'lib/pg/basic_type_map_for_results.rb', line 79
def typecast_result_value(result, _tuple, field) format = result.fformat(field) oid = result.ftype(field) unless @already_warned.dig(format, oid) warn "Warning: no type cast defined for type #{@typenames_by_oid[oid].inspect} format #{format} with oid #{oid}. Please cast this type explicitly to TEXT to be safe for future changes." unless frozen? @already_warned[format] ||= {} @already_warned[format][oid] = true end end super end