beancount / beanquery

A customizable lightweight SQL query tool that works on tabular data, including Beancount.
GNU General Public License v2.0
20 stars 12 forks source link

CSV output broken #167

Closed mmoya closed 8 months ago

mmoya commented 8 months ago

CSV output is broken in 2bf6dfb. Text output works OK.

  ...
  File "/home/mmoya/.cache/pypoetry/virtualenvs/mmoya-ledger-YHEMojRP-py3.11/lib/python3.11/site-packages/beanquery/query_render.py", line 548, in <listcomp>
    renderers = [_get_renderer(column.datatype, ctx) for column in columns]
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mmoya/.cache/pypoetry/virtualenvs/mmoya-ledger-YHEMojRP-py3.11/lib/python3.11/site-packages/beanquery/query_render.py", line 467, in _get_renderer
    return renderer(ctx)
           ^^^^^^^^^^^^^
  File "/home/mmoya/.cache/pypoetry/virtualenvs/mmoya-ledger-YHEMojRP-py3.11/lib/python3.11/site-packages/beanquery/query_render.py", line 307, in __init__
    self.units_renderer = AmountRenderer(ctx)
                          ^^^^^^^^^^^^^^^^^^^
  File "/home/mmoya/.cache/pypoetry/virtualenvs/mmoya-ledger-YHEMojRP-py3.11/lib/python3.11/site-packages/beanquery/query_render.py", line 235, in __init__
    self.quantize = ctx.dcontext.quantize
                    ^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_io.TextIOWrapper' object has no attribute 'quantize'

Last working commit was 804087a.

mmoya commented 8 months ago

This fixes the problem:


diff --git a/beanquery/render/csv.py b/beanquery/render/csv.py
index 01bd097..c979a83 100644
--- a/beanquery/render/csv.py
+++ b/beanquery/render/csv.py
@@ -2,4 +2,4 @@ from ..query_render import render_csv

 def render(desc, rows, file, *, dcontext, **kwargs):
-    return render_csv(desc, rows, file, dcontext, **kwargs)
+    return render_csv(desc, rows, dcontext, file, **kwargs)