lib/base_repo.rb
# Take the attributes to be inserted/updated on a table
# and convert any arrays/hashes into their appropriate
# database-specific types.
#
# @param table_name [Symbol, Sequel::SQL::QualifiedIdentifier] the table name (or qualified name)
# @param args [hash,dry validation result] the attributes to apply.
# @return [hash] the modified attributes suitable for the DB.
Take the attributes to be inserted/updated on a table
and convert any arrays/hashes into their appropriate
database-specific types.
Take the attributes to be inserted / updated on a table and convert any arrays / hashes into their appropriate database - specific types .
def prepare_values_for_db(table_name, args)
    return nil if args.nil?
    hash = args.to_h.clone
    hash.each do |k, v|
      case column_type(table_name, k)
      when :integer_array
        hash[k] = array_for_db_col(v)
      when :string_array
        hash[k] = array_for_db_col(v, array_type: :text)
      when :jsonb
        hash[k] = hash_for_jsonb_col(v)
      end
    end
    hash
  end
def prepare_values_for_db ( table_name , args ) return nil if args . nil? hash = args . to_h . clone hash . each do | k , v | case column_type ( table_name , k ) when :integer_array hash [ k ] = array_for_db_col ( v ) when :string_array hash [ k ] = array_for_db_col ( v , array_type : :text ) when :jsonb hash [ k ] = hash_for_jsonb_col ( v ) end end hash end
Take the attributes to be inserted/updated on a table
and convert any arrays/hashes into their appropriate
database-specific types.
Take the attributes to be inserted / updated on a table and convert any arrays / hashes into their appropriate database - specific types .
the modified attributes suitable for the DB.
the modified attributes suitable for the DB .
hash
table_name
the table name (or qualified name)
the table name ( or qualified name )
args
the attributes to apply.
the attributes to apply .