kolofordjango / kolo

See everything happening in your running Django app. All without leaving VSCode
https://kolo.app
512 stars 14 forks source link

SQL Queries can't be copy pasted #66

Closed yml closed 1 year ago

yml commented 1 year ago

kolo version: 2.9.0 db is mysql

I can't copy paste SQL queries captured by kolo:

SELECT
  ` redirects_redirect `.` id `,
  ` redirects_redirect `.` created `,
  ` redirects_redirect `.` modified `,
  ` redirects_redirect `.` old_path `,
  ` redirects_redirect `.` new_path `
FROM
  ` redirects_redirect `
WHERE
  ` redirects_redirect `.` old_path ` = '/test/'
LIMIT 1

The issue is caused by the space ` after and before the. I a bit puzzled on why I have such behavior because else where in the ticket tracker I have seen query without space.

Screenshot from 2023-08-16 09-43-09

wilhelmklopp commented 1 year ago

@yml hey! great to see you on here 👋

This is pretty strange indeed, maybe some issue with how our sql formatting library is handling mysql/backticks.

Would you be able to check one thing for me: Open the raw trace in VSCode:

image

Then search for end_sql_query and paste the value you see for query:

image

Just trying to make sure that we're saving it properly in the first place, without the extra spaces.

yml commented 1 year ago

@wilhelmklopp I have been here all along :-)

It looks like it is saved properly may be the vscode extension does not display it as it should.

    {
      "database": "mysql",
      "frame_id": "frm_01H7Z351BYVECP8BP2VMXSC77C",
      "return_timestamp": 1692186871.1696987,
      "query_template": "SELECT `redirects_redirect`.`id`, `redirects_redirect`.`created`, `redirects_redirect`.`modified`, `redirects_redirect`.`old_path`, `redirects_redirect`.`new_path` FROM `redirects_redirect` WHERE `redirects_redirect`.`old_path` = %s LIMIT 21",
      "query": "SELECT `redirects_redirect`.`id`, `redirects_redirect`.`created`, `redirects_redirect`.`modified`, `redirects_redirect`.`old_path`, `redirects_redirect`.`new_path` FROM `redirects_redirect` WHERE `redirects_redirect`.`old_path` = '/test' LIMIT 21 /**/",
      "query_data": [],
      "thread": "MainThread",
      "thread_native_id": 248920,
      "timestamp": 1692186871.1696987,
      "type": "end_sql_query"
    },
wilhelmklopp commented 1 year ago

@yml I just releases a new version of the vscode extension which should fix this mysql formatting issue – let me know if it works 🤞

yml commented 1 year ago

@wilhelmklopp thank you. The problem is solved.

I can now copy paste happily :-) May be it is just me but every time I do I need to add a ; at the end to run the query but this is another topic and may be more controversial.

wilhelmklopp commented 1 year ago

May be it is just me but every time I do I need to add a ; at the end to run the query but this is another topic and may be more controversial.

Ah yeah that's kind of interesting – never quite noticed this 🤔

@LilyFoote do you know why the SQL we capture doesn't include the ;? does django for some reason not need to send the ; to execute the query?

yml commented 1 year ago

Most of my use cases of the SQL Query made tab for me involve copy a query and pasting it in a terminal directly or prefixed by EXPLAIN ANALIZE FORMAT=tree