title: How to pass an array of customs type to a PostgreSQL function
body: <p>I have a custom array type in Postgres:</p>
  
  <pre><code>CREATE TYPE core.arr_message_input AS (
      idmessage uuid,
      idplugin integer,
      versionplugin numeric,
      ttl integer
  );
  </code></pre>
  
  <p>There is a simple function to add records to the table:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION queue_push(
      arr_message_input[])
      RETURNS Bool
      LANGUAGE 'plpgsql'
  AS $$
      BEGIN
          INSERT INTO queue(idmessage, idplugin, versionplugin, queuetime, ttl)
          SELECT idmessage, idplugin, versionplugin, now(), ttl
          FROM unnest ($1);
          RETURN True;
      EXCEPTION
          WHEN others THEN
              RETURN False;
      END $$;
  </code></pre>
  
  <p>Filling in values from Postgres is easy:</p>
  
  <pre><code>SELECT queue_push(
      array[
          ('e62c7924-2cd1-4dd6-9b55-d4e612816ce0', 2, 0, 0),
          ('a7e864af-4c4c-452d-9df2-f9d4f70ac02e', 2, 0, 0),
      ]::arr_message_input[]
  );
  </code></pre>
  
  <p>But through SQLAlchemy I can't figure out how to do it. I pass it a list as an array, but there should be a list of lists or something similar. And I have no way of doing it from Python.</p>
  
  <p>For example:</p>
  
  <p>The function model is described as follows:</p>
  
  <pre><code>class QueuePush(GenericFunction):
  
      name = "queue_push"
  
      @staticmethod
      def mapped_objects(**kwargs):
          return select(
              [
                  Column('queue_push', BOOLEAN),
              ]
          ).select_from(
              func.queue_push(
                  kwargs['arr_message_input'],
              )
          ).alias(name="queue_push")
  </code></pre>
  
  <p>Request to the function:</p>
  
  <pre><code>import QueuePush
  
  
  messages = [
      ['027d6e96-84b7-4f10-8640-13dfa1b05fd8', 3, 0, 2],
  ]
  
  queue = db.query(QueuePush.mapped_objects(arr_message_input=messages)).all()
  </code></pre>
  
  <p>But still, the created type is a kind of data structure. I'm obviously doing something wrong.</p>