Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROCEDURE shopping_cart_add_product() sends incorrect item_id value type with UUID() #18

Open
elig0n opened this issue May 12, 2019 · 2 comments

Comments

@elig0n
Copy link

elig0n commented May 12, 2019

Definition of item_id is INT as seen here:

CREATE TABLE `shopping_cart` (
`item_id`     INT           NOT NULL  AUTO_INCREMENT,

calling procedure shopping_cart_add_product() with adequate results in

Error: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect integer value: 'f93b1c05-74d4-11e9-b143-3497f6a16369' for column `tshirtshop`.`shopping_cart`.`item_id` at row 1

Mistake is in INSERT-ing item_id as UUID() which is NOT an INT type.
line #1003:

VALUES (UUID(), inCartId, inProductId, inAttributes, 1, NOW());

"UUID() returns a value that conforms to UUID version 1 as described in RFC 4122. The value is a 128-bit number represented as a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format:"

From: https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid

Observed on MariaDB 10.3.14

@elig0n elig0n changed the title PROCEDURE shopping_cart_add_product() bad item_id value from UUID() PROCEDURE shopping_cart_add_product() sends incorrect item_id value type with UUID() May 12, 2019
@edertaveiraturing
Copy link

Please use Mysql 5.7.X.

@elig0n
Copy link
Author

elig0n commented Jun 2, 2019

Please use Mysql 5.7.X.

The UUID() function in MySQL 5.7.X uses hex characters as well

The only solution I have found is to modify the PROCEDURE to either pass a '0' as item_id or not pass it all (as the next ID will be given to it automatically because it's an autoincrement'ed field).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants