itsgoingd / clockwork

Clockwork - php dev tools in your browser - server-side component
https://underground.works/clockwork
MIT License
5.66k stars 323 forks source link

Is PostgresSQL supported? #579

Closed screw closed 2 years ago

screw commented 2 years ago

I installed clockwork with CLOCKWORK_STORAGE=sql. The logging is working, but when I try to filter requests, the SQL query fails. The prepare method throws an exception with the following message:

#message: """
    SQLSTATE[42703]: Undefined column: 7 ERROR:  column "commandname" does not exist
    LINE 1: ...OM clockwork WHERE (uri LIKE $1 OR uri LIKE $2 OR commandNam...
                                                                 ^
    HINT:  Perhaps you meant to reference the column "clockwork.commandName".

The query:

$query: "SELECT "id", "version", "type", "time", "method", "url", "uri", "headers", "controller", "getData", "postData", "requestData", "sessionData", "authenticatedUser", "cookies", "responseTime", "responseStatus", "responseDuration", "memoryUsage", "middleware", "databaseQueries", "databaseQueriesCount", "databaseSlowQueries", "databaseSelects", "databaseInserts", "databaseUpdates", "databaseDeletes", "databaseOthers", "databaseDuration", "cacheQueries", "cacheReads", "cacheHits", "cacheWrites", "cacheDeletes", "cacheTime", "modelsActions", "modelsRetrieved", "modelsCreated", "modelsUpdated", "modelsDeleted", "redisCommands", "queueJobs", "timelineData", "log", "events", "routes", "notifications", "emailsData", "viewsData", "userData", "subrequests", "xdebug", "commandName", "commandArguments", "commandArgumentsDefaults", "commandOptions", "commandOptionsDefaults", "commandExitCode", "commandOutput", "jobName", "jobDescription", "jobStatus", "jobPayload", "jobQueue", "jobConnection", "jobOptions", "testName", "testStatus", "testStatusMessage", "testAsserts", "clientMetrics", "webVitals", "parent", "updateToken" FROM clockwork WHERE (uri LIKE :uri0 OR uri LIKE :uri1 OR commandName LIKE :commandName0 OR commandName LIKE :commandName1 OR jobName LIKE :jobName0 OR jobName LIKE :jobName1 OR testName LIKE :testName0 OR testName LIKE :testName1) ORDER BY id DESC LIMIT 1"

I tried playing around and what looks like works with Postgres is modifying SqlSearch.php resolveXXXCondition() methods.

I removed the curly brackets and replaced them with escaped quotes like so: return "\"$field\" > :{$field}{$index}"; (line 78).

Better solution would be similar to SqlStorage::quote() method.

What do you guys think?

itsgoingd commented 2 years ago

Included as part of Clockwork 5.1.7.