"Type not supported" error for the default varchar in Postgres. Why?
In developing an ER diagram for Postgres, I always get "type not supported" error for the default varchar. If I don't change anything, it warns me about % sign, if I leave the () blank then I get a warning, which is better than an error, but this isn't great.
Am I missing something?
Thanks,
willie
Solution
I believe the behavior is correct. Let's go through all the cases you described.
First of all, the default varchar (that is one without lenght) has syntax: "varchar" or "character varying". You can write it this way in "Type" field and you get no error:
tests=> CREATE TABLE def_varchar ( tests(> id int NOT NULL, tests(> code varchar NOT NULL, tests(> CONSTRAINT def_varchar_pk PRIMARY KEY (id) tests(> ); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "def_varchar_pk" for table "def_varchar" CREATE TABLE
Then, if you try either "varchar()" or "varchar(%)", both Vertabelo and PostgreSQL will raise an error:
tests=> CREATE TABLE def_varchar ( tests(> id int NOT NULL, tests(> code varchar() NOT NULL, tests(> CONSTRAINT def_varchar_pk PRIMARY KEY (id) tests(> ); ERROR: syntax error at or near ")" LINE 3: code varchar() NOT NULL, ^
tests=> CREATE TABLE def_varchar ( tests(> id int NOT NULL, tests(> code varchar(%) NOT NULL, tests(> CONSTRAINT def_varchar_pk PRIMARY KEY (id) tests(> ); ERROR: syntax error at or near "%" LINE 3: code varchar(%) NOT NULL, ^
Please note that the list of data types is only a helper to choose the most common ones. You can provide any text you want into the "Type" field. Vertabelo either warns you or raises an error if it doesn't recognize the type, but you can ignore it if you like.
Hope this helps.
Service d'assistance aux clients par UserEcho
I believe the behavior is correct. Let's go through all the cases you described.
First of all, the default varchar (that is one without lenght) has syntax: "varchar" or "character varying". You can write it this way in "Type" field and you get no error:
Database accepts it without warning:Then, if you try either "varchar()" or "varchar(%)", both Vertabelo and PostgreSQL will raise an error:
Please note that the list of data types is only a helper to choose the most common ones. You can provide any text you want into the "Type" field. Vertabelo either warns you or raises an error if it doesn't recognize the type, but you can ignore it if you like.
Hope this helps.