Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Install Error - Unique Values In Table - Fails at SQL 23 Sep 2012 07:03 #3873

  • BTB300
  • BTB300's Avatar Topic Author
  • Offline
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132
Hi
I have a custom user details table that has two fields (username and email) that are defined as needing to be unique

The error => JInstaller: :Install: Error SQL DB function failed with error number 1071
Specified key was too long; max key length is 1000 bytes

This is not really a J-Cook Issue but its related to MySql Limits and UTF-8 encoding!!!

From my understanding (please correct me if i am wrong) in UTF-8 it takes 3 bytes to store one character this would then explain why the above error is encountered with the following fields defined as unique

`username` VARCHAR(150) + `email` VARCHAR(255) = (150 x 3) + (255 x 3) = 1215 bytes

THE WORKAROUND:
Reduce the allowed length of the unique strings

THE FORMULA
(uniqueStringLength1 x 3) + (uniqueString2Length2 x 3) +( uniqueString3Length3 x 3) + .... >= 1000

I Have confirmed that cook will build without error using the following for unique values for my situation
`username` VARCHAR(78) + `email` VARCHAR(255) = (78 x 3) + (255 x 3) = 999 bytes

As indicated above this is not a cook issue but related to the limits of MySql and UTF-8 Encoding

The reason i placed it in the new tickets is to suggest that the unique value option possibly be handled at the component level (validation for instance) rather than at the database level to allow more than one unique field per table

Regards
BTB300
The following user(s) said Thank You: JoomGuy

Please Log in or Create an account to join the conversation.

Last edit: by BTB300.

Install Error - Unique Values In Table - Fails at SQL 25 Sep 2012 18:06 #3987

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
This is a VERY good catch.

Well, the builder cannot reduce anything without asking the user.
All it can do is making a global check before to build.

I am about to create a validator for the builder, which check the integrity of the project before to build.
So, I will include your advice.

Karma +1
Coding is now a piece of cake
The following user(s) said Thank You: JoomGuy

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.074 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started