Inserting an array using Sequel gem in PostgreSQL

前端 未结 3 882
星月不相逢
星月不相逢 2020-12-12 03:54

i created a table with the following schema in code

DB.create_table :Pokemon do
  primary_key :id
  String :first_name
  String :last_name
  String :email
           


        
3条回答
  •  一生所求
    2020-12-12 04:18

    In your database config:

    DB.extension :pg_array

    Then just convert each array to type PGArray:

    pokes.insert(:first_name => 'abcd' ,:last_name => 'mehandiratta', :offering => Sequel.pg_array(off) , :needs => Sequel.pg_array(nee))

    @Jeremy Evans' answer provides a link to the docs which include a more succinct way to do it if using the core-extensions extension.

提交回复
热议问题