Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4374 closed (duplicate) custom sql fails with triggers and sqlite

Reported by: hambaloney@… Owned by: jacob
Component: Uncategorized Version: 0.96
Severity: Keywords: custom sql trigger sqlite3
Cc: hambaloney@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Ran into an issue where using the interface to bring in custom SQL containing triggers for sqlite causes it to fail with the error:

The full error: near ";": syntax error

Dug around to find in django/core/ -> get_custom_sql_for_model, the sql commands are parsed by semicolons.

sqlite triggers follow the format:

database-event ON [database-name .] table-name
trigger step;
trigger step;
END; attempts to parse and run each line ending in a semicolon separately causing the error.

As a temporary fix I've modified as follows, please don't hurt me, I know its ugly. Note, I'm using sqlite3.

Attachments (1)

management.diff (951 bytes) - added by hambaloney@… 8 years ago.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by hambaloney@…

comment:1 Changed 8 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

This is a dupe of problems mentioned in #3214, amongst other places. We don't support multi-line or complex SQL data in initial SQL files and it's not clear we ever will (because we would essentially have to write a generic SQL parser that understood the SQL for every single backend we support).

If somebody every comes up with a neat, truly generic solution, we'll lok at it, but micro-fixes like this unfortunately cause more trouble than they're worth, because every change impacts some other use-case and we end up chasing our tail forever.

comment:2 Changed 8 years ago by mtredinnick

Last comment was by me. Not sure why Trac decided I was anonymous (since I was logged in at the time).

Note: See TracTickets for help on using tickets.
Back to Top