Type endpoint parameters and bind them into project DB SQL - #38096
Draft
MartinRiese wants to merge 5 commits into
Draft
Type endpoint parameters and bind them into project DB SQL#38096MartinRiese wants to merge 5 commits into
MartinRiese wants to merge 5 commits into
Conversation
With '' queries like
(:weight IS NULL OR number_prop__weight > :weight)
Fail on
invalid input syntax for type numeric: ""
LINE 3: ...D ('' = '' OR projectdb_mriese.pet.number_prop__weight > '')
Adds a daterange parameter type and the two functions that map a search request onto the placeholders an endpoint's SQL leaves unbound. daterange is parameter-only: no case property has that type, so it has no operations and the existing slot-type check rejects it in an Elasticsearch query spec without needing a special case. It derives two placeholders, :<name>_from and :<name>_to, which parse_parameter_spec now guards against colliding with another parameter's name. bind_values decides arity from the declared type rather than from what was searched for, so an endpoint's SQL works whatever arrives: a select parameter is always a list, everything else always a scalar, and multiple values for a scalar are a user error rather than a 500 out of psycopg2. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
get_project_db_results now binds through the endpoint's parameter spec instead of passing every placeholder the raw criterion value. Date ranges and multi-select criteria reach Postgres in a shape it can use, where before they arrived as '__range__...' or a Python list and failed as an uncaught DataError. A project DB endpoint must now declare the parameters its SQL references. The spec is validated when the endpoint is saved, so a stored spec that does not parse is reported as a bug rather than as the searcher's fault. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reports at save time what would otherwise fail when the endpoint runs: a placeholder the spec does not declare, or a declared parameter the SQL never uses, both of which UserSQL.run rejects as BadParameters. Two shape checks come from the compiled binds. A parameter used with IN renders nothing at all when unsupplied, so its NULL guard raises an IndexError out of psycopg2 rather than anything a caller can report. And a select parameter holds a list, so it has to be compared with a select_prop__ array column using && or @> -- comparing a list against a text column is an "operator does not exist" error, and a bare string against an array column silently matches nothing. UserSQL grows parameter_binds, exposing what parameters already computed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds the daterange and select options, both gated to project DB endpoints since neither has an operation in the query builder, and shows the placeholder names each parameter derives so a daterange's :<name>_from and :<name>_to are visible rather than documented elsewhere. The SQL card gains a note on guarding parameters with IS NULL and on comparing a select parameter against a select_prop__ column. The README covered only Elasticsearch endpoints, so it gains the binding rules and a section on the project DB target. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
MartinRiese
force-pushed
the
riese/cs_endpoints_number_param
branch
from
September 2, 2026 18:42
a72893a to
0225f4a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Product Description
Technical Summary
Feature Flag
Safety Assurance
Safety story
Automated test coverage
QA Plan
Migrations
RemoveField,RenameField,RemoveConstraint, and others described here that can cause errors when migrations are applied to a live database.Rollback instructions
Labels & Review