{
  "db_name": "PostgreSQL",
  "query": "\n        WITH first AS (\n            SELECT\n              true AS first, false AS last, values,\n              a.normal_balance_type AS \"normal_balance_type!: DebitOrCredit\",\n              all_time_version\n            FROM cala_cumulative_effective_balances\n            JOIN cala_accounts a\n            ON account_id = a.id\n            WHERE journal_id = $1\n            AND account_id = $2\n            AND currency = $3\n            AND effective < $4\n            ORDER BY effective DESC, version DESC\n            LIMIT 1\n        ),\n        last AS (\n            SELECT\n              false AS first, true AS last, values,\n              a.normal_balance_type AS \"normal_balance_type!: DebitOrCredit\",\n              all_time_version\n            FROM cala_cumulative_effective_balances\n            JOIN cala_accounts a\n            ON account_id = a.id\n            WHERE journal_id = $1\n            AND account_id = $2\n            AND currency = $3\n            AND effective <= COALESCE($5, NOW()::DATE)\n            ORDER BY effective DESC, version DESC\n            LIMIT 1\n        )\n        SELECT * FROM first\n        UNION ALL\n        SELECT * FROM last\n        ",
  "describe": {
    "columns": [
      {
        "ordinal": 0,
        "name": "first",
        "type_info": "Bool"
      },
      {
        "ordinal": 1,
        "name": "last",
        "type_info": "Bool"
      },
      {
        "ordinal": 2,
        "name": "values",
        "type_info": "Jsonb"
      },
      {
        "ordinal": 3,
        "name": "normal_balance_type!: DebitOrCredit",
        "type_info": {
          "Custom": {
            "name": "debitorcredit",
            "kind": {
              "Enum": [
                "debit",
                "credit"
              ]
            }
          }
        }
      },
      {
        "ordinal": 4,
        "name": "all_time_version",
        "type_info": "Int4"
      }
    ],
    "parameters": {
      "Left": [
        "Uuid",
        "Uuid",
        "Text",
        "Date",
        "Date"
      ]
    },
    "nullable": [
      null,
      null,
      null,
      null,
      null
    ]
  },
  "hash": "8dc4984c9dc757869e6a1c8b83c1c30d03552f59f077bf67e48866297c6e143e"
}
