Midburn / spark

"burn in a box" suite of services that composes everything required to run a burn event throughout the year
Apache License 2.0
18 stars 46 forks source link

camps/new should create new camp #249

Closed netanelben closed 7 years ago

netanelben commented 7 years ago

Reproduce:

  1. go to http://sparkstaging.midburn.org/he/camps/new?c=yo%20yo%20yo
  2. Click save
  3. Error occurred

Error report:

{"error":true,"data":{"message":"insert into `camps` (`__prototype`, `accept_families`, `camp_activity_time`, `camp_desc_en`, `camp_desc_he`, `camp_location_area`, `camp_location_street`, `camp_location_street_time`, `camp_name_en`, `camp_name_he`, `child_friendly`, `contact_person_email`, `contact_person_id`, `contact_person_name`, `contact_person_phone`, `created_at`, `event_id`, `facebook_page_url`, `location_comments`, `main_contact`, `moop_contact`, `noise_level`, `public_activity_area_desc`, `public_activity_area_sqm`, `safety_contact`, `status`, `support_art`, `type`, `updated_at`) values ('theme_camp', '0', '', 'camp', 'camp', '', '', '', 'yo yo yo', 'my camp', '0', '', '', '', '', 'Fri Apr 07 2017 12:01:09 GMT+0000 (UTC)', 'MIDBURN2017', '', '', '', '', 'quiet', '', '', '', 'open', '0', '', 'Fri Apr 07 2017 12:01:09 GMT+0000 (UTC)') - ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`spark`.`camps`, CONSTRAINT `camps_main_contact_foreign` FOREIGN KEY (`main_contact`) REFERENCES `users` (`user_id`))"}}
asihud commented 7 years ago

the problem is because we trying to write a foreign key value which does not exists. (0 does not exists...) we need to check if the value is empty, no need to write it.

asihud commented 7 years ago

okay, i am refactoring the new / edit to work as it should, not to add the contact id and all foreign keys if they are bad.

asihud commented 7 years ago

this was fixed in pr #256