UUID for PK

SofaRide

New member
I've noticed that in all of the tutorial videos an auto-incrementing int is used for the primary key. Is this a requirement? I'd very much prefer to use UUIDs for the PK. Will this cause any issues?
 

eugenio

Administrator
Staff member
Hello,
good question, at the moment there are two features that require an auto increment field:

- after insert hook: if the related table doesn't have an auto increment field, you don't get the id of the record just inserted in your hook function

- insert "other choice": if you haver a lookup field and you allow the insertion of additional fields ("Other choices allowed?" in form configurator) you need an auto increment field in the linked table

Best,
 

SofaRide

New member
Thank you Eugenio! I think for our application, these will we acceptable trade-offs. One other concern I have, I notice the PK is used in the URL when editing specific records. best practice is generally to encode the UUID as a 16 byte binary. Will Databik handle the URL encoding/decoding for this without errors? Or do I need to use a VARCHAR instead?
 

eugenio

Administrator
Staff member
Hello,
it probably depends on the way the binary data is produced, in some cases you won't have problems and in some other you probably will, because the PK value in DaDaBIK is just encoded via urlencode() before passing it to the URL; so my advise is to use VARCHAR instead.

Best,
 

SofaRide

New member
eugenio Wrote:
-------------------------------------------------------
> the PK value in DaDaBIK is just encoded via urlencode() b
> efore passing it to the URL

Where is the DBO code? Maybe I can just add a test for binary and covert too base64 on the DBO getter?
 

eugenio

Administrator
Staff member
It's in /include/db_functions_pdo.php, you can do that but I think the risk of missing something here is high and you'll have to apply again the modification when you upgrade DaDaBIK.

I'll take note of this aspect and I'll think about it for the future, though.

Best,
 
Top