calpoly-csai / api

Official API for the NIMBUS Voice Assistant accessible via HTTP REST protocol.
https://nimbus.api.calpolycsai.com/
GNU General Public License v3.0
9 stars 4 forks source link

save_clubs endpoint fails to save a club #79

Closed mfekadu closed 4 years ago

mfekadu commented 4 years ago

Describe the bug

sqlalchemy.exc.DataError: (mysql.connector.errors.DataError) 1406 (22001): Data too long for column 'contact_phone' at row 1
[SQL: INSERT INTO `Clubs` (club_name, types, `desc`, contact_email, contact_email_2, contact_person, contact_phone, box, advisor, affiliation) VALUES (%(club_name)s, %(types)s, %(desc)s, %(contact_email)s, %(contact_email_2)s, %(contact_person)s, %(contact_phone)s, %(box)s, %(advisor)s, %(affiliation)s)]
[parameters: {'club_name': 'test_club', 'types': 'Academic, Special Interest', 'desc': 'description', 'contact_email': 'test@test.com', 'contact_email_2': 'test@test.com', 'contact_person': 'Test Person', 'contact_phone': 15552223232, 'box': 89, 'advisor': 'Test Person', 'affiliation': None}]
(Background on this error at: http://sqlalche.me/e/9h9h)

-->

========================================= 1 failed, 1 passed in 5.70s =========================================
➜  tests git:(mf-patch-and-test) ✗

discovered by new tests from #80

mfekadu commented 4 years ago

@austinsilveria any clues on this bug?

austinsilveria commented 4 years ago

@mfekadu Looks like the contact_phone column in the Clubs Entity is set to take a String with max length 10. I didn't run into this issue when populating the table with scraped clubs, but it might be worth it to increase the size a bit for safety.

mfekadu commented 4 years ago

@austinsilveria , I agree.

What size is reasonable? Should we bother supporting all kinds of contact_phone formats or expect normalized data?

adamperlin commented 4 years ago

@mfekadu maybe just double the max size, for now, to be safe?

mfekadu commented 4 years ago

@adamperlin @austinsilveria okay I'll make it double in my next PR within the next few minutes

mfekadu commented 4 years ago

has been fixed

https://github.com/calpoly-csai/api/blob/48336b06f95e3676c5322d6760c34968b2d145d5/Entity/Clubs.py#L17