{
  "db_name": "PostgreSQL",
  "query": "\n                SELECT\n                    u.user_id as \"user_id!\",\n                    COALESCE(c.balance, 0) + COALESCE(delta.sum, 0) as \"balance!\"\n                FROM unnest($1::uuid[]) AS u(user_id)\n                LEFT JOIN user_balance_checkpoints c ON c.user_id = u.user_id\n                LEFT JOIN LATERAL (\n                    SELECT SUM(\n                        CASE WHEN transaction_type IN ('admin_grant', 'purchase') THEN amount ELSE -amount END\n                    ) as sum\n                    FROM credits_transactions t\n                    WHERE t.user_id = u.user_id\n                    AND t.seq > COALESCE(c.checkpoint_seq, 0)\n                ) delta ON true\n                ",
  "describe": {
    "columns": [
      {
        "ordinal": 0,
        "name": "user_id!",
        "type_info": "Uuid"
      },
      {
        "ordinal": 1,
        "name": "balance!",
        "type_info": "Numeric"
      }
    ],
    "parameters": {
      "Left": [
        "UuidArray"
      ]
    },
    "nullable": [
      null,
      null
    ]
  },
  "hash": "37c3f69985efca58c60bb66edc8ac698fbb53842620860a4cfe44585a76006e3"
}
