question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SQL Tick marks not highlighting as a string

See original GitHub issue

Information

  • Language: SQL, MySQL
  • Plugins: none

image

Description

When using ` marks to surround a keyword, the word should be formatted as a string.

Adding a tick to this fixes the issue:

Prism.languages.sql = {
	'string': {
		pattern: /(^|[^@\\])("|'|`)(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
		greedy: true,
		lookbehind: true
	},
}
The code being highlighted incorrectly.
select
   `t`.`col1`, `t`.`col2`, `t`.`col3`, `t`.`col4` 
from
   `test_table` as `t`

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
RunDevelopmentcommented, Oct 6, 2021

just adding my own style (not sure if this is the best approach):

That’s the way to go. You can always change and extend Prism’s themes if they aren’t to your liking 😃

0reactions
RunDevelopmentcommented, Oct 7, 2021

It’s an identifier, so I am somewhat against highlighting it differently from other identifiers. E.g. Foo and `Foo` are two different ways to refer to the same column/table/user. The only difference is that quoted identifiers support special characters, non-ASCII characters, and keywords. E.g. `Foo*`, `😊`, `SELECT`.

(There are also a few other languages that have quoted identifiers like this.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tick marks in Sql Statements - MSDN - Microsoft
It's stored and processed as a single tick. I'm updating a table with about 12,000 records and I'm doing it with variables.
Read more >
When to use single quotes, double quotes, and backticks in ...
Backticks are to be used for table and column identifiers, but are only necessary when the identifier is a MySQL reserved keyword, ...
Read more >
PL/SQL statement returning a query — oracle-tech
My problem is the tick marks in the query. I can't seem to get them right because the entire SQL statement has to...
Read more >
SET QUOTED_IDENTIFIER settings in SQL Server
This article gives an overview of the QUOTED_IDENTIFIER set option and its behaviour in SQL Server queries with single and double-quotes.
Read more >
5 shortcuts in SQL Prompt you didn't know about
END block, or a TRY…CATCH block. These snippets utilise the $SELECTEDTEXT$ placeholder, so highlight your block of code, hit Ctrl and type BE...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found