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

Nicer error message when before insert/update trigger fails #80

Open
malaire opened this issue Oct 18, 2016 · 0 comments
Open

Nicer error message when before insert/update trigger fails #80

malaire opened this issue Oct 18, 2016 · 0 comments

Comments

@malaire
Copy link

malaire commented Oct 18, 2016

This is probably easy to fix while fixing #74 but since this is a bit different, I created separate issue.

I have BEFORE INSERT and BEFORE UPDATE triggers on table which prevent some invalid entries with SIGNAL SQLSTATE '45000'. For example:

CREATE TRIGGER `PageRedirect_bi` BEFORE INSERT ON `PageRedirect`
FOR EACH ROW
  # UrlName must also be unique with Page.UrlName
  IF (EXISTS(SELECT * FROM Page WHERE UrlName = NEW.UrlName)) THEN
    SIGNAL SQLSTATE '45000';
  END IF

When trying to save new or updated record with invalid values, Xataface dies with uncaught exception instead of handling this gracefully.

PHP Fatal error: Uncaught exception 'Exception' with message 'Failed to update due to sql error: Unhandled user-defined exception condition' in
/xataface-2.1.3/Dataface/IO.php:1033
Stack trace:

0 /xataface-2.1.3/Dataface/IO.php(678): Dataface_IO->_update(Object(Dataface_Record), Array, 'PageRedirect', true)

1 /xataface-2.1.3/Dataface/QuickForm.php(1142): Dataface_IO->write(Object(Dataface_Record), Array, NULL, true, false)

2 [internal function]: Dataface_QuickForm->save(Array)

3 /xataface-2.1.3/lib/HTML/QuickForm.php(1632): call_user_func(Array, Array)

4 /xataface-2.1.3/actions/edit.php(130): HTML_QuickForm->process(Array)

5 /xataface-2.1.3/Dataface/Application.php(2426): dataface_actions_edit->handle(Array)

6 /xataface-2.1.3/Dataface/Application.php(2578): Dataface_Application->handleRequest(false)

7 /xataface-2.1.3/Dataface/Application.php(2447): Dataface_Application->_display(false, false)

...

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

1 participant