PostgreSQL uuid type query

Hi guys,

I am new to Servoy and application development in general.

I have created a PostgreSQL DB and a ‘users’ table from within Servoy. I left the default primary key of ‘user_uuid’, type 'UUID (DB Native), Sequence Type ‘uuid generator’ and disabled allow null.

I am trying to manually add a row of data into the table via PG Admin 4 by running the below command:

INSERT INTO users (email, first_name, last_name)
VALUES ('test@test.com', 'Bill', 'Peters');

However when doing to I get the below error:

null value in column "user_uuid" violates not-null constraint

It was my understanding I shouldn’t have to pass a value and that the user_uuid should be automatically generated due to it having the sequence type of ‘uuid generator’ in Servoy.

What am I missing here? Any assistance would be much appreciated.

Cheers guys! :D

Alex.

Hi Alex,

there are two strategies:

  • get Servoy to insert the primary key
  • get the database, in your case PostgreSQL to do it.

If you pick the first, this will make it more difficult to add data to your database outside of Servoy (like from pgAdmin).
You can use pgAdmin to modify the primary key of your table to insert the UUID when records are created.

Take a look at something like

https://arctype.com/blog/postgres-uuid/

Hope this helps,

Thank you Christian for your informative response!

I will certainly reply here if I have any further issues/queries.

Cheers,

Alex :)