Formatting SQL Queries from the SugarCRM.log file

Ever since prepared queries appeared in Sugar it has made debugging queries a lot more challenging.  When you set your log level to INFO and collect the suspect queries you are presented with queries that look like this

SELECT meetings.id, meetings.date_modified meetings__date_modified FROM meetings LEFT JOIN meetings_users meetings_users ON (meetings.id = meetings_users.meeting_id) AND (meetings_users.deleted = ?) LEFT JOIN users jt0_users ON (jt0_users.id = meetings_users.user_id) AND (jt0_users.deleted = ?) WHERE ((meetings.reminder_time >= ?) AND (meetings.status = ?) AND (meetings_users.accept_status != ?) AND (meetings.date_start BETWEEN ? AND ?) AND (jt0_users.id = ?)) AND (meetings.deleted = ?) ORDER BY meetings.date_modified DESC, meetings.id DESC LIMIT 21\nParams: {"1":0,"2":0,"3":0,"4":"Planned","5":"decline","6":"2021-01-25 01:47:49","7":"2021-01-26 01:52:49","8":"1","9":0}\nTypes: {"1":5,"2":5,"3":1,"4":2,"5":2,"6":2,"7":2,"8":2,"9":5}

Maybe I am wrong and there is an easy way to turn this into something I can run in Workbench or phpMyAdmin but so far I haven't found it.  So I created sqlViewer.  It allows me to not only reformat these queries it makes it easier to find the right query in my log file and I can run it right from the interface.  It also strips out all the fluff that copying things from the log file ad like line feed and carrage returns.

Main Screen

There probably isn't much to learn from this one but I have found it invaluable on many occasions.  All the code and instructions for the loadable module are available at https://github.com/kenbrill/sqlViewer.  You are welcome to submit improvements and bug fixes if you want to.

Anonymous
Parents
  • I have been told that the SQL console in JetBrains products will accept SQL with placeholders and then allow you to fill in the params manually.  I tried this but many of my queries had long lists of '0's and '1's and it was just too difficult to keep straight over and over.  But it does work so there is at least 1 way to run the queries outside of this.

Comment
  • I have been told that the SQL console in JetBrains products will accept SQL with placeholders and then allow you to fill in the params manually.  I tried this but many of my queries had long lists of '0's and '1's and it was just too difficult to keep straight over and over.  But it does work so there is at least 1 way to run the queries outside of this.

Children
No Data