How can I create a column that is of the same type as a column in some
other table?

I am using: DB.schema(another) table to retrieve field type:


def type_of_field(field_name)
    field_name = field_name.to_sym
    f = @connection.schema(@table_name).detect { |f| f[0] ==
field_name }
    if f
        return f[1][:type]
    end
    return nil
end

and then I use it in:

field_type = type_of_field(field)
@connection.create_table(some_other_table) do
    ....
    column field, field_type
    ....
end

For some types it does not work, such as text in Postgres which will
be :string in Sequel and then string back in Postgres - which is
undefined:

    PGError: ERROR:  type "string" does not exist

Is there any way how to achieve this? At least within single database
adapter (for example - original, non-converted column type name would
help).

Thanks,

Stefan

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to