-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please add SQL support #10
Comments
@oxygen |
Some MySQL SQL with variables concatenated using const strQuery = `
-- Test comment
-- Some other comment about.someQueue.else
SELECT
queue.id,
queue.timestamp,
queue.someInt,
queue.column
FROM queue
/* Block comment */
LEFT JOIN queue AS queue_blocked ON (
queue_blocked.id_blocked IS NOT NULL
AND
/*
Block comment
Block comment
*/
queue_blocked.type IN ('someQueue')
AND
queue_blocked.id_blocked = queue.id
AND
queue_blocked.status NOT IN ('success', 'failed')
)
WHERE
-- Comment about noQueue
queue_blocked.id IS NULL
AND
queue.type IN ('someQueue')
AND
queue.status NOT IN ('success', 'failed')
AND
(
(
queue.retry_count < queue.retry_max
-- Avoid running this too often (too soon)
AND
UNIX_TIMESTAMP(TIMESTAMP(NOW())) - UNIX_TIMESTAMP(TIMESTAMP(REPLACE(REPLACE(queue.updated_timestamp, 'T', ' '), 'Z', ''))) >= queue.retry_min_sec
)
OR
queue.call_count = 0
)
-- Slow subquery replaced by LEFT JOIN + WHERE filtering trick.
/*AND
NOT EXISTS (
SELECT
1 AS it_exists
FROM queue AS queue_A
WHERE
-- Optimization, doesn't affect results.
queue_A.type IN ('someQueue')
-- Optimization, doesn't affect results.
AND
queue_A.status NOT IN ('success', 'failed')
-- Optimization, doesn't affect results.
-- This optimization made the whole query 5 (five) times faster.
AND
(
queue_A.group_id = queue.group_id
OR
(
queue_A.group_id IS NULL
AND
queue.group_id IS NULL
)
)
-- The mandatory condition
AND
queue_A.id_blocked = queue.id
LIMIT 1
)*/
AND
(
queue.id_blocked_by IS NULL
OR
NOT EXISTS(
SELECT
1 AS it_exists
FROM queue AS queue_C
WHERE
(
queue_C.group_id = queue.group_id
OR
(
queue_C.group_id IS NULL
AND
queue.group_id IS NULL
)
)
AND
queue_C.id = queue.id_blocked_by
LIMIT 1
)
)
AND
(
queue.id NOT IN (${this.runningQueueIDs().length ? this.runningQueueIDs().join(",") : 0})
OR
(
queue.mark_for_death IN ('kill' ,'stop_retrying', 'kill_and_stop_retrying')
AND
queue.process_info_json IS NOT NULL
AND
JSON_EXTRACT(queue.process_info_json, "$.property") = ${escape(arch())}
AND
JSON_EXTRACT(queue.process_info_json, "$.pid") = ${escape(strSomeJavaScriptStringVar)}
)
)
ORDER BY
queue.id ASC
LIMIT ${this._objQueueConfig.max_workers - this.runningQueueIDs().length}
`; It should be colored like how VS Code already colors inside normal .sql files. |
Flawless. If you have StackOverflow, drop an answer here please: And I will award you a large bounty. Thank you very much!!! |
I left SO a few years ago. So, feel free to answer your question and accept it. Sorry about that. Feel free to make any suggestions or report a bug. Feel free to close this issue, when you will check SQL support |
All good. |
You are a life saver.
Would it be difficult to add SQL support in the same way (the same SQL support VS code comes prepacked with)?
The text was updated successfully, but these errors were encountered: