Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

318
Visualizações
Inconsistent output format of Postgres query

I'm querying a Postgres database for 3 varchar(n) fields like follows:

Select ("Title","Author","Isbn") from public."Book" Where 1=1

The output of the query is a tuple with 3 strings. However the formatting of output is sometimes inconsistent between records. Note the output of the query:

enter image description here

Notice the difference in the first element between row 40 and row 41/42. The first element of row 40 is "Revolutionary Road" (wrapped in double quotes). The first element of row 41 is Neuromancer (not wrapped in quotes). The same phenomena occurs elsewhere in the query set as well.

I'm not sure why this first element is sometimes inconsistent in how it's returned by the query. It's not an issue with the individual records themselves. What else might be wrong?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The result is correct. In this output format, Postgres use quotes when string has spaces or some special chars:

postgres=# select row('ahoj', 'ahoj svete', 'ahoj,svete', '"ahoj svete"');
┌───────────────────────────────────────────────────┐
│                        row                        │
╞═══════════════════════════════════════════════════╡
│ (ahoj,"ahoj svete","ahoj,svete","""ahoj svete""") │
└───────────────────────────────────────────────────┘
(1 row)

If you don't want output format of composite value, don't use a row constructor:

postgres=# select 'ahoj', 'ahoj svete', 'ahoj,svete', '"ahoj svete"';
┌──────────┬────────────┬────────────┬──────────────┐
│ ?column? │  ?column?  │  ?column?  │   ?column?   │
╞══════════╪════════════╪════════════╪══════════════╡
│ ahoj     │ ahoj svete │ ahoj,svete │ "ahoj svete" │
└──────────┴────────────┴────────────┴──────────────┘
(1 row)
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda