Class: PG::BasicTypeMapForResults::WarningTypeMap

Inherits:
TypeMapInRuby
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/basic_type_map_for_results.rb

Instance Method Summary collapse

Constructor Details

#initialize(typenames) ⇒ WarningTypeMap

Returns a new instance of WarningTypeMap.



54
55
56
57
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/basic_type_map_for_results.rb', line 54

def initialize(typenames)
	@already_warned = Hash.new{|h, k| h[k] = {} }
	@typenames_by_oid = typenames
end

Instance Method Details

#typecast_result_value(result, _tuple, field) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/basic_type_map_for_results.rb', line 59

def typecast_result_value(result, _tuple, field)
	format = result.fformat(field)
	oid = result.ftype(field)
	unless @already_warned[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."
		 @already_warned[format][oid] = true
	end
	super
end