/ Development  

Exceed number of follow up zeros

Hi there AppWorks fans,

Welcome to a new installment of AppWorks tips.

This time we do a small test on what will happen when you exceed to follow up zeros on the crafted identity for an entity…This was a question we had in some earlier post.

Maybe can remember the question, but this is the related screenshot for that question where we see the ‘Identity’ building block for our ‘Category’ entity.

zeros_001

This ‘business ID’ is shown (in our case) on de ‘Default’ form and you see the value increasing when you create a new instance of this ‘Category’ entity in the front-end.

zeros_002

But what happens when we reach the end of all the zeros!!??


Let get right into it…

What we can do is just ‘hack’ into the database and update an entity row to the latest value possible in the column ‘s_item_business_id’, but I don’t know if that might break things.

For now, we use the save route where we create a ‘Test’ entity with the business ID prefixed with ‘tst_’ and a minimum number of digits set to 1.

zeros_003

This way we only need to create 9 instances to see a result on the 10th!

Create those 2 forms (‘Create’ and ‘Default’) where we expose the business ID on the ‘Create’ form and re-use the ‘Create’ form on the ‘Default’ form.

Note that the business ID is getting a value after creation of a new instance of the ‘Category’ entity.

zeros_004

Also quickly create an ‘AllTests’ list building block so we can find things back.

After saving and publishing it is time for…


The big test!

Go to the front-end ‘/app/start’ and start by creating 9 instances of the new ‘Test’ entity…

zeros_005

And now for the 10th…What will happen??

Hit it!!

zeros_006

It’s magic! 😜

Is it?

So, when I have 1 follow up zeros starting with ‘tst_01’; at value 10 we would also get ‘tst_10’; at value 99 we would get ‘tst_99’; And value 100 will just be ‘tst_100’.

Nothing breaks…So what is the point of using the follow up zeros option?

For that I would like to point to the leading zeros page on wikipedia

But again, how long can the business ID be?

For that we dive into the database again with HeidiSQL with this query SELECT COLUMN_NAME, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_precision_radix, numeric_scale, udt_name FROM information_schema.COLUMNS WHERE TABLE_NAME = 'o2appworkstipsappworkstest';

zeros_007

And there we see that the ‘s_item_business_id’ is a ‘varchar’ type with a character length of 40!


Ok…Let’s go back to the entity and see if we can break some stuff…

This is a valid configuration where the prefix is also 20 characters. So, in total we have 40 chars.

zeros_008

And we get off-course an error when we exceed the total length of 40!

zeros_009

So…unbreakable for how long?

Well, the max value will be testtesttesttesttes_99999999999999999999 after this one we would get testtesttesttesttes_100000000000000000000, but this exceeds that max. length of 40.

But before we are there, we need to create 99.999.999.999.999.999.999 instances of the entity!?

Yes, that is 99 quintillion (got that from math.com) instances of an entity…Well, a small change that will happen in my life as a consultant…howdy! 🤠


And that my dear AppWorks friends brings us to the ‘DONE’ for our post. Nice to check out the limits of a system and we see that things might (eventually) break also, but the chance is rather small.

If you want me to do more of these kinds of checks, you are free to post something in the comment so we can pick it up in the future. Have a good one for now and I see you in the next one.

Ohhh…And don’t forget to subscribe to get updates on the activities happening on this site.