Closed jeffreyrlewis closed 3 years ago
Hi @jeffreyrlewis, thanks for bringing this up. I know that this used to be a feature of postgres-nio. However I'm discussing with @0xTim where this should live in the future.
In my mind explicitly printing the SQL queries is only necessary for ORM frameworks. For this reason this debugging logic should also, in my view, live in the ORM level and not in database driver itself. Users who use plain postgres-nio always know their SQL queries, since the only option is to write them out by hand. Would you consider raising this issue against fluent or sql-kit?
However postgres-nio has a quite extensive .trace
logging to debug the connection state. In those logs you will also find the SQL query. To enable this use logLevel = .trace
. Be aware that this will print A LOT of logs. (Do not use this in production!)
Thanks for your response. I see your point. Happy to raise it against the appropriate other module ... sql-kit seems like it might be the most appropriate, but would be happy for @0xTim to weigh in on that.
FYI - I raised it as a bug because I didn't (on an admittedly quick scan) see it in the documentation / changelogs that the change had been (intentionally) made.
Thanks for pointing out that .trace will do the trick, but indeed, as you'd expect, I'd rather not have to go to trace level to see SQL ;-)
BTW, I just had reason to turn on .trace debugging. However, I do not see SQL in the logs.
Transferring here as this is where it should be solved. Resolved by #180
Describe the bug
In version 1.4.4 and earlier, with debug logging turned on, you would see the raw SQL in the logs. In the current version you only get an abstracted representation of the query, which isn't helpful for sorting out subtle SQL problems.
To Reproduce
Set LOG_LEVEL=debug and run any query. I currently get log message like: [ DEBUG ] query read courses filters=[courses[slug] = "en-ast-main"]
I don't believe there's anything special or unusual in my configuration, but let me know if I need to supply any details.
Expected behavior
With 1.4.4, I get in addition to the above, the much more useful: [ DEBUG ] SELECT "courses"."id" AS "courses_id", "courses"."name" AS "courses_name", "courses"."slug" AS "courses_slug", "courses"."source_language_id" AS "courses_source_language_id", "courses"."target_language_id" AS "courses_target_language_id", "courses"."creator_id" AS "courses_creator_id", "courses"."seed_set_id" AS "courses_seed_set_id", "courses"."script_status" AS "courses_script_status", "courses"."reverse_translation" AS "courses_reverse_translation", "courses"."preborg" AS "courses_preborg", "courses"."created_at" AS "courses_created_at", "courses"."updated_at" AS "courses_updated_at" FROM "courses" WHERE "courses"."slug" = $1 ["en-ast-main"]
This is what I expect to see.
Environment
Additional context
Add any other context about the problem here.