Class: Lore::Type_Filters
- Defined in:
- lib/lore/adapters/postgres/types.rb,
lib/lore/adapters/postgres-pr/types.rb
Constant Summary collapse
- @@input_filters =
{ PG_VCHAR_LIST => lambda { |v| "{#{v.join(',')}}" }, PG_BOOL => lambda { |v| if (v && v != 'f' || v == 't') then 'f' elsif (v.instance_of?(FalseClass) || v == 'f') then 'f' else nil end }, PG_DATE => lambda { |v| v.to_s }, PG_TIME => lambda { |v| v.to_s }, PG_TIMESTAMP_TIMEZONE => lambda { |v| v.to_s }, PG_TIMESTAMP => lambda { |v| v.to_s }, }
- @@output_filters =
{ PG_VCHAR_LIST => lambda { |v| v[1..-2].split(',') }, PG_INT => lambda { |v| if v then v.to_i else nil end }, PG_SMALLINT => lambda { |v| if v then v.to_i else nil end }, PG_FLOAT => lambda { |v| if v && v.length > 0 then v.to_f else nil end }, PG_DECIMAL => lambda { |v| if v && v.length > 0 then v.to_f else nil end }, PG_BOOL => lambda { |v| if v == 't' then true elsif v == 'f' then false else nil end } # SLOW! # PG_DATE => lambda { |v| Date.parse(v) if v }, # PG_TIME => lambda { |v| Time.parse(v) if v }, # PG_TIMESTAMP_TIMEZONE => lambda { |v| DateTime.parse(v) if v }, # PG_TIMESTAMP => lambda { |v| DateTime.parse(v) if v } }