This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
The following commit(s) were added to refs/heads/trunk by this push:
new 2938f67 Switch from M_ prefix to Q_
2938f67 is described below
commit 2938f676ad43316c2a21bb11837860cc357f4c34
Author: Greg Stein <[email protected]>
AuthorDate: Fri Sep 26 09:16:48 2025 -0500
Switch from M_ prefix to Q_
The old steve-specific db.py could not provide column names for
arbitrary SELECT statements, so some were named "m_foo" to distinguish
them because of bare-tuple return values. The asfpy.db module properly
handles all SELECTs, so we don't need the "m_" prefix distinction.
Rename all M_FOO to Q_FOO.
---
v3/queries.yaml | 10 ++++------
v3/steve/election.py | 14 +++++++-------
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/v3/queries.yaml b/v3/queries.yaml
index a6fe6f2..3474f16 100644
--- a/v3/queries.yaml
+++ b/v3/queries.yaml
@@ -21,7 +21,6 @@
# CURSOR NAMING:
# c_* performs various actions
# q_* runs queries
-# m_* runs queries that don't fit "SELECT *" pattern ($reasons)
#
election:
@@ -57,22 +56,21 @@ election:
q_get_mayvote: SELECT * FROM mayvote WHERE pid = ? AND iid = ?
q_tally: SELECT * FROM mayvote WHERE iid = ?
q_by_issue: SELECT * FROM vote WHERE issue_token = ? ORDER BY _ROWID_
-
- m_find_issues: |
+ q_find_issues: |
SELECT m.*
FROM mayvote m
JOIN issue i ON m.iid = i.iid
WHERE m.pid = ? AND i.eid = ?
- m_has_voted: |
+ q_has_voted: |
SELECT 1 FROM vote
WHERE vote_token = ?
LIMIT 1
- m_recent_vote: |
+ q_recent_vote: |
SELECT ciphertext FROM vote
WHERE vote_token = ?
ORDER BY _ROWID_ DESC
LIMIT 1
- m_all_issues: |
+ q_all_issues: |
SELECT m._ROWID_
FROM mayvote m
JOIN issue i ON m.iid = i.iid
diff --git a/v3/steve/election.py b/v3/steve/election.py
index f621751..c34b4f4 100644
--- a/v3/steve/election.py
+++ b/v3/steve/election.py
@@ -137,11 +137,11 @@ class Election:
# The Election should be editable.
assert self.is_editable()
- # Use M_ALL_ISSUES to iterate over all Person/Issue mappings
+ # Use Q_ALL_ISSUES to iterate over all Person/Issue mappings
# in this Election (specified by EID).
self.db.conn.execute('BEGIN TRANSACTION')
- self.m_all_issues.perform(self.eid)
- for mayvote in self.m_all_issues.fetchall():
+ self.q_all_issues.perform(self.eid)
+ for mayvote in self.q_all_issues.fetchall():
# MAYVOTE is a 1-tuple: _ROWID_
#print('COLUMNS:', dir(mayvote))
@@ -263,7 +263,7 @@ class Election:
)
# We don't need/want all columns, so only pick CIPHERTEXT.
- row = self.m_recent_vote.first_row(vote_token)
+ row = self.q_recent_vote.first_row(vote_token)
votestring = crypto.decrypt_votestring(
vote_token, mayvote.salt, row.ciphertext,
)
@@ -288,8 +288,8 @@ class Election:
voted_upon = { }
- self.m_find_issues.perform(pid, self.eid)
- for row in self.m_find_issues.fetchall():
+ self.q_find_issues.perform(pid, self.eid)
+ for row in self.q_find_issues.fetchall():
#print('COLUMNS:', dir(row))
# Query is mayvote.* ... so ROW is: PID, IID, SALT
@@ -298,7 +298,7 @@ class Election:
)
# Is any vote present? (wicked fast)
- voted = self.m_has_voted.first_row(vote_token)
+ voted = self.q_has_voted.first_row(vote_token)
voted_upon[row.iid] = (voted is not None)