PostgreSQL uuid type query

Q&A regarding installation and issues getting started with Servoy

PostgreSQL uuid type query

Postby amitchell » Sat Apr 09, 2022 2:41 pm

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:

Code: Select all
INSERT INTO users (email, first_name, last_name)
VALUES ('[email protected]', 'Bill', 'Peters');


However when doing to I get the below error:

Code: Select all
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.
Attachments
pg_admin_error.png
pg_admin_error.png (25.67 KiB) Viewed 3576 times
users_table_servoy.png
users_table_servoy.png (13 KiB) Viewed 3576 times
amitchell
 
Posts: 6
Joined: Sun Mar 13, 2022 4:31 pm

Re: PostgreSQL uuid type query

Postby swingman » Sat Apr 09, 2022 2:58 pm

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,
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1479
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: PostgreSQL uuid type query

Postby amitchell » Mon Apr 11, 2022 12:49 pm

Thank you Christian for your informative response!

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

Cheers,

Alex :)
amitchell
 
Posts: 6
Joined: Sun Mar 13, 2022 4:31 pm


Return to I'm just getting started

Who is online

Users browsing this forum: No registered users and 1 guest

cron