Skip to content

Commit

Permalink
Cleanup definition of the Row class
Browse files Browse the repository at this point in the history
  • Loading branch information
dnicolodi committed Nov 14, 2024
1 parent 553f8b3 commit b84722c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions beanquery/query_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,24 +867,22 @@ def update(self, store, context):
class Row:
"""A dumb container for information used by a row expression."""

rowid = None
def __init__(self):
self.rowid = 0
self.balance = inventory.Inventory()

# The current posting being evaluated.
posting = None
# The current transaction of the posting being evaluated.
entry = None

# The current transaction of the posting being evaluated.
entry = None
# The current posting being evaluated.
posting = None

# The context hash is used in caching column accessor functions.
# Instead than hashing the row context content, use the rowid as
# hash.
def __hash__(self):
# The context hash is used in caching column accessor functions.
# Instead than hashing the row context content, use the rowid as
# hash.
return self.rowid

def __init__(self, entries, options):
self.rowid = 0
self.balance = inventory.Inventory()


class BeanTable(tables.Table):
def __init__(self, entries, options, open=None, close=None, clear=None):
Expand Down Expand Up @@ -1041,7 +1039,7 @@ class PostingsTable(EntriesTable):

def __iter__(self):
entries = self.prepare()
context = Row(entries, self.options)
context = Row()
for entry in entries:
if isinstance(entry, data.Transaction):
context.entry = entry
Expand Down

0 comments on commit b84722c

Please sign in to comment.