Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Feature: supporting optional arguments in named/favourite queries?

Abierto
#143 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
postgresql, python, sql
Área
cli, databases

Línea de trabajo

Comienza rastreando el manejo existente de \n NAME ARGS... para consultas con nombre y favoritas en pgspecial. Resuelve la sintaxis de los argumentos opcionales y el comportamiento ante valores faltantes, incluidos los parámetros agregados; después, añade cobertura para invocaciones con y sin argumentos opcionales, preservando los fallos existentes para los argumentos requeridos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Hopefully this is the right place, since as best I can tell, the code for \n NAME ARGS... as provided by pgcli actually lives in here.

It would be convenient if there was a way to specify optional arguments to be replaced in a named query, to allow something like:

\ns opt-args select * from some_table where ($?1 is null or some_field like '%$?1%')

so it could be invoked as either \n opt-args with no args to just query everything, or if \n opt-args somevalue to filter to only things matching that argument, without needing to have different queries with/without args (and remembering which you want to use at the time)

I've invented the $?<num> format in the above example which doesn't currently exist. That allows it to be distinguished from normal arguments as they are now, to avoid breaking existing behaviour of the invocation failing if there are unreplaced parameters left.

I'm currently imagining that the optional arg would just be substituted with the value NULL if not present, although a case could be made for a more bash-like ${VAR:-DEFAULT} to allow arbitrary replacement values if not provided.

It might make sense to allow optional aggregated params as well, although not sure if they should expand to an empty list, or also to NULL.

I think I can probably cobble up a PR if there's any interest, but figured it might be wise to check first, and maybe bikeshed the syntax before ploughing ahead 😄

Lenguaje dominante
Python
Estrellas
86
Forks
54
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dbcli/pgspecial

Todos los issues de dbcli/pgspecial

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.