jakob / jakob/Postico

Functions with `DEFAULT nextval()` break autocomplete + function view

Open
#874 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
486
Forks
8
PR merge metrics
No merged PRs in 30d

Description

## What did you do?

- I created the following reduced test-case function with a parameter defaulted to `nextval`:
- ```sql
CREATE SEQUENCE IF NOT EXISTS test_seq;
CREATE OR REPLACE FUNCTION public.test(id integer DEFAULT nextval('test_seq'))
RETURNS boolean
RETURN false;
```
- Notably, changing out `nextval` for a different function call, ie `degrees(0.5)` seemed to remove the issue. I'm not sure exactly what part of the `nextval` call is breaking the parser, but it's clearly not the function call.
- I typed in the SQL editor
- I opened the function view from the sidebar entry `test (integer)`

## What did you expect to happen?

- I expected autocomplete to work
- I expected the function view to work

## What actually happened?

- Autocomplete failed and the following error popped up:

![Screenshot 2024-03-24 at 1 32 39 PM](https://github.com/jakob/Postico/assets/430411/866c1c18-28bd-4e52-899d-e33f350f4882)

- The function viewer failed and the following error popped up:
![image](https://github.com/jakob/Postico/assets/430411/c3bc3f20-0953-4167-b494-6e91bdadec3c)

## What software versions are you using?

**Postico version:** 2.1 (9682)
**macOS version:** Sonoma 14.3
**PostgreSQL version:** 16.1

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue in the SQL editor with the provided CREATE SEQUENCE and CREATE FUNCTION statements against PostgreSQL 16.1, then inspect the autocomplete and sidebar entry `test (integer)` function-view paths. Done means the `nextval` default no longer causes either view to fail and autocomplete works for the reproduced case.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
databases, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.