Skip to content

Fix PostgreSQL query placeholders and console type imports - #69

Merged
dfeen87 merged 1 commit into
mainfrom
codex/perform-bug-focused-code-review
Sep 27, 2026
Merged

dfeen87 merged 1 commit into
mainfrom
codex/perform-bug-focused-code-review

Conversation

@dfeen87

@dfeen87 dfeen87 commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Ensure PostgreSQL usage via psycopg receives correctly formatted parameter placeholders when shared SQLite-style ? queries are reused.
  • Prevent runtime NameError in Streamlit helpers by adding the missing typing names used in nested helper annotations.
  • Provide regression coverage for the PostgreSQL code paths to avoid future regressions.

Description

  • Add a _postgres_query helper in cura_frame/db.py that converts ? placeholders to psycopg-compatible %s and apply it to execute, fetchone, and fetchall PostgreSQL branches.
  • Import from typing import Any, Dict in apps/console_streamlit/app.py to satisfy nested helper annotations used by the Streamlit UI.
  • Add a unit test test_postgres_operations_convert_qmark_placeholders to tests/test_console_db_auth.py exercising execute, fetchone, and fetchall against a fake Postgres cursor to verify placeholder conversion and result shaping.

Testing

  • Ran pytest -q and confirmed test suite success with 191 passed (warnings shown but unrelated to these changes).
  • Ran pytest -q tests/test_console_db_auth.py tests/test_web.py which passed (coverage of the added regression test included).
  • Ran ruff check and python -m compileall to validate style/type imports and byte-compile the package, both completed without errors.

Codex Task

Copilot AI lite review requested due to automatic review settings September 27, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@dfeen87
dfeen87 merged commit 51383de into main Sep 27, 2026
2 checks passed
@dfeen87
dfeen87 deleted the codex/perform-bug-focused-code-review branch September 27, 2026 20:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 911f727a78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cura_frame/db.py

def _postgres_query(query: str) -> str:
"""Convert the qmark placeholders used by callers to psycopg's format."""
return query.replace("?", "%s")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve non-placeholder question marks

When a caller submits valid PostgreSQL syntax containing a question mark that is not a qmark binding—such as the JSONB existence expression payload ? 'key'—this unconditional replacement turns the operator into %s, causing psycopg to interpret it as a parameter placeholder and reject or misexecute the query. Translate only actual bind markers, or use dialect-specific query strings, so PostgreSQL operators and question marks in literals/comments remain intact.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants