vscode-postgres icon indicating copy to clipboard operation
vscode-postgres copied to clipboard

Support for SERIAL data type

Open Ryukote opened this issue 5 years ago • 4 comments

Hello,

will there be a support for SERIAL data type soon?

Ryukote avatar Apr 02 '19 21:04 Ryukote

Perhaps I need more clarification... Support how exactly - showing "SERIAL" in the database explorer or column headers, syntax highlighting, or problem checking?

SERIAL is essentially an INT column with auto-increment applied. In fact running a \d on a table with a column doesn't show SERIAL as a type even in postgres.

test_db=# create table test_serial (ID SERIAL);
CREATE TABLE
test_db=# \d
                 List of relations
 Schema |        Name        |   Type   |  Owner
--------+--------------------+----------+----------
 public | test_serial        | table    | postgres
 public | test_serial_id_seq | sequence | postgres
(2 rows)

test_db=# \d test_serial
                         Table "public.test_serial"
 Column |  Type   |                        Modifiers
--------+---------+----------------------------------------------------------
 id     | integer | not null default nextval('test_serial_id_seq'::regclass)

If postgres doesn't report it as a SERIAL type, then I can't either.

Borvik avatar Apr 03 '19 10:04 Borvik

Yea, sorry about missing more information. When I type basic create table and use SERIAL as a data type for example for "Id" column, SERIAL keyword is underlined and running query throws me an error. I am not at home at the moment, so I can't give you exact error message. It is like SERIAL is not recognized as a keyword, so I can't use it.

It is a syntax sugar that is there in the Postgres and I would like to use it.

Ryukote avatar Apr 03 '19 10:04 Ryukote

Yea...

Running the query should still work. That errors is from EXPLAIN as that is what power the error checking for the underlines.

postgres=# \c test_db
You are now connected to database "test_db" as user "postgres".
test_db=# EXPLAIN CREATE TABLE test_serial (id SERIAL);
ERROR:  syntax error at or near "SERIAL"
LINE 1: EXPLAIN CREATE TABLE test_serial (id SERIAL);
                                             ^

In order to really solve this I need to implement some sort of node language parser/validator that can handle multiple versions of a language.

Borvik avatar Apr 03 '19 10:04 Borvik

Ok, so it is not a bug, just a missing feature?

Ryukote avatar Apr 03 '19 11:04 Ryukote