FAI-CIVL / FAI-Airscore

AirScore - online paragliding / hanggliding GAP-based scoring software.
https://airscore.cc/
GNU General Public License v3.0
13 stars 17 forks source link

change pilot & Participant name field to varchar 100 #208

Closed philderbeast closed 3 years ago

philderbeast commented 3 years ago

Trying to import the *.fsdb for the 2018 XC Dalmatian Paragliding Open I get an database write error:

sqlalchemy.exc.DataError: (pymysql.err.DataError) (1406, "Data too long for column 'name' at row 1")
[SQL: INSERT INTO `tblParticipant` (comp_id, civl_id, `ID`, name, birthdate, sex, nat, glider, sponsor,
fai_valid, nat_team) VALUES (%(comp_id)s, %(civl_id)s, %(ID)s, %(name)s, %(birthdate)s, %(sex)s, %(nat)s, %(glider)s,
%(sponsor)s, %(fai_valid)s, %(nat_team)s)]
[parameters: {'comp_id': 6, 'civl_id': 70252, 'ID': 80, 'name': 'Ricardo Nicolau Soares Terra De Oliveira Figueiredo',
'birthdate': datetime.date(1963, 2, 16), 'sex': 'M', 'nat': 'POR', 'glider': 'Nova - Phantom', 'sponsor': 'FLYMASTER',
'fai_valid': True, 'nat_team': 1}]
(Background on this error at: http://sqlalche.me/e/13/9h9h)
kuaka commented 3 years ago

that is a very long name! in airscore the name is max 50 chars. What is the max length in FS? we should match it otherwise truncate long names before DB writes.

biuti commented 3 years ago

I asked Elena how they store in CIVL database

kuaka commented 3 years ago

I asked Elena how they store in CIVL database

great. we (someone who knows their way around the code) should check FS length. Then airscore can be set to the max of the two.

philderbeast commented 3 years ago

I generated a long string in ghci and then pasted that as the name of a participant in FS. This was truncated to 100 characters with no warning about the truncation.

ghci> concat [ x : show y | x <- ['A'..'Z'], y <- [0..9]]
"A1A2A3A4A5A6A7A8A9B1B2B3B4B5B6B7B8B9C1C2C3C4C5C6C7C8C9D1D2D3D4D5D6D7D8D9E1E2E3E4E5E6E7E8E9F1F2F3F4F5F6F7F8F9G1G2G3G4G5G6G7G8G9H1H2H3H4H5H6H7H8H9I1I2I3I4I5I6I7I8I9J1J2J3J4J5J6J7J8J9K1K2K3K4K5K6K7K8K9L1L2L3L4L5L6L7L8L9M1M2M3M4M5M6M7M8M9N1N2N3N4N5N6N7N8N9O1O2O3O4O5O6O7O8O9P1P2P3P4P5P6P7P8P9Q1Q2Q3Q4Q5Q6Q7Q8Q9R1R2R3R4R5R6R7R8R9S1S2S3S4S5S6S7S8S9T1T2T3T4T5T6T7T8T9U1U2U3U4U5U6U7U8U9V1V2V3V4V5V6V7V8V9W1W2W3W4W5W6W7W8W9X1X2X3X4X5X6X7X8X9Y1Y2Y3Y4Y5Y6Y7Y8Y9Z1Z2Z3Z4Z5Z6Z7Z8Z9"

-- pasted into FS, saved participant, then copied finding that 100 of the characters remain.
ghci> length "A0A1A2A3A4A5A6A7A8A9B0B1B2B3B4B5B6B7B8B9C0C1C2C3C4C5C6C7C8C9D0D1D2D3D4D5D6D7D8D9E0E1E2E3E4E5E6E7E8E9"
100

ghci> length "Ricardo Nicolau Soares Terra De Oliveira Figueiredo"
51
philderbeast commented 3 years ago

Name is 100 chars for CIVL WPRS too.


CREATE TABLE _ (
...
    [name] NVARCHAR (100) NOT NULL,
...
);
kuaka commented 3 years ago

@biuti hasn't this been done? can it be closed?

kuaka commented 3 years ago

actually looking at the very non-descript https://github.com/FAI-CIVL/FAI-Airscore/commit/b897917899c07b0d9e929d5b0746db11d1894010 only the tables have been updated. There still needs to be handling of the case a name longer than 100 chars is submitted

biuti commented 3 years ago

With https://github.com/FAI-CIVL/FAI-Airscore/commit/032604b2c6bb869cfb466648e4e02365ce74ae65 I added form validation to participant add and edit functions in pilot_admin, and also error reporting in participants importing functions from FSDB and excel files. Now it is possible to create Flashed Messages from javascript (https://github.com/FAI-CIVL/FAI-Airscore/commit/8f5ef80be9d6d08163e1f716055e0cd6fd092921) so I'll try to add error reporting as much as I manage in other scripts.